Answer:
Following are the definition of function
double averager (const double &x) // function definition
{
static double z = 0.0; // variable declaration
static size_t c = 0;
c=c+1; // increment of c by 1
z =z+ x; // adding value
return z /c ; // return average
}
Explanation:
Following are the description of statement
- Create a function averager of double type that holds a parameter "x" of the double type .
- In this function we declared a variable "z" of a static double type that value is initialized by 0.
- The static variable is used to retain value.
- Declared a variable "c" of size_t type that holds a value 0 .
- After that increment the value of c by 1 .
- adding the value of "z" variable to the "x" and storing the result into the z variable.
- Finally return the average value
Answer:
n = int(input("Enter the n (positive odd integer): "))
for i in range(1, n+1, 2):
print(i*"*")
for i in range(n-2, 0, -2):
print(i*"*")
Explanation:
*The code is in Python.
Ask the user to enter the n
Create a for loop that iterates from 1 to n, incrementing by 2 in each iteration. Print the corresponding number of asterisks in each iteration
Create another for loop that iterates from n-2 to 1, decrementing by 2 in each iteration. Print the corresponding number of asterisks in each iteration
Let P(n) be "a postage of n cents can be formed using 5-cent and 17-cent stamps if n is greater than 63".Basis step: P(64) is true since 64 cents postage can be formed with one 5-cent and one 17-cent stamp.Inductive step: Assume that P(n) is true, that is, postage of n cents can be formed using 5-cent and 17-cent stamps. We will show how to form postage of n + 1 cents. By the inductive hypothesis postage of n cents can be formed using 5-cent and 17-cent stamps. If this included a 17-cent stamp, replace this 17-cent stamp with two 5-cent stamps to obtain n + 1 cents postage. Otherwise, only 5-cent stamps were used and n 65. Hence there are at least three 5-cent stamps forming n cents. Remove three of these 5-cent stamps and replace them with two 17-cent stamps to obtain n + 1 cents postage.Hence P(n + 1) is true.
Answer:
The program in C++ is as follows:
#include<iostream>
using namespace std;
void displayData(int height, int length, double Area){
printf("Height: %d \n", height);
printf("Length: %d \n", length);
printf("Area: %.2f \n", Area);
}
double trigArea(int height, int length){
double area = 0.5 * height * length;
displayData(height,length,area);
return area;
}
void getData(){
int h,l;
cin>>h>>l;
trigArea(h,l);
}
int main(){
getData();
return 0;
}
Explanation:
<em>See attachment for complete program where comments are used to explain the solution</em>
Resource management, you can think of the necter and pollen as resources and you are managing other bees to collect those resources.