60 463
Assignments Done
98,1%
Successfully Done
In April 2018

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

Expert's answer
int arrayofnumbers[20];
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[0]);

return 0;
}

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

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

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

}
return maximum;

}

double Minimum(){
double minimum=arrayofnumbers[0];
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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions