# Answer to Question #18905 in C++ for Miriam

Question #18905
write a program in c which computes and prints product, difference, maximum, minimum, average, sum and modular
int arrayofnumbers;
double Product();
double Difference();
double Maximum();
double Minimum();
double Average();
double Sum();
double Modular();
int main()
{

for(int i=0;i<20;i++){
printf("Enter number %d: ",(i+1));
scanf("%d",&arrayofnumbers[i]);
}

printf("
Product = %f",Product());
printf("
Difference = %f",Difference());
printf("
Maximum = %f",Maximum());
printf("
Minimum = %f",Minimum());
printf("
Average = %f",Average());
printf("
Sum = %f",Sum());
printf("
Modular = %f",Modular());

printf("
Press any key to exit...");
scanf("%d",&arrayofnumbers);

return 0;
}

double Product(){
double product=1;
for(int i=0;i<20;i++){
product*=arrayofnumbers[i];
}
return product;

}
double Difference(){
double difference=arrayofnumbers;
for(int i=1;i<20;i++){
difference-=arrayofnumbers[i];
}
return difference;

}
double Maximum(){
double maximum=arrayofnumbers;
for(int i=0;i<20;i++){
if(arrayofnumbers[i]>maximum){
maximum =arrayofnumbers[i];
}

}
return maximum;

}

double Minimum(){
double minimum=arrayofnumbers;
for(int i=0;i<20;i++){
if(arrayofnumbers[i]<minimum){
minimum =arrayofnumbers[i];
}

}
return minimum;

}
double Average(){
double sum=0;
for(int i=0;i<20;i++){
sum+=arrayofnumbers[i];

}
return sum/20;
}

double Sum(){
double sum=0;
for(int i=0;i<20;i++){
sum+=arrayofnumbers[i];
}
return sum;
}

double Modular(){
double modular=0;
for(int i=0;i<20;i++){
modular =arrayofnumbers[i]%2;
}
return modular;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!