64 693
Assignments Done
99,3%
Successfully Done
In September 2018

Answer to Question #19208 in C++ for MK

Question #19208
write a program that ask the user to insert 3 ingers numbers between 1-100 and display the following menu
a-display maximum
b-display minimum
Expert's answer
int Maximum();
int Minimum();
int arrayofnumbers[3];
int main()
{
char ch=' ';
for(int i=0;i<3;i++){
printf("Enter number %d: ",i+1);
scanf("%d",&arrayofnumbers[i]);
}

printf("a-display maximum
");
printf("b-display minimum
");
ch=getchar();
ch=getchar();
if(ch=='a'){
printf("Maximum= %d",Maximum());
}
if(ch=='b'){
printf("Minimum= %d",Minimum());
}

int k;
scanf("%d",&k);
return 0;
}


int Maximum() {
int max=arrayofnumbers[0];
for(int i=0;i<3;i++){
if(arrayofnumbers[i]>max){
max=arrayofnumbers[i];
}
}
return max;
}

int Minimum() {
int min=arrayofnumbers[0];
for(int i=0;i<3;i++){
if(arrayofnumbers[i]<min){
min=arrayofnumbers[i];
}
}
return min;
}

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