Answer to Question #28243 in C++ for Max Lek

Question #28243
Use if-else statement, write down a C code to assign the maximum of a and b to an integer variable called Max.
1
Expert's answer
2013-04-15T11:26:24-0400
//main function
int main()
{
int a,b;//variable a and b
printf("Enter number a: ");//Enter number a
scanf("%d",&a);
printf("Enter number b: ");//Enter number b
scanf("%d",&b);
//show result
if(a>b){
printf("Max is a = %d",a);
}else{
printf("Max is b= %d",b);
}
scanf("%d",&a);//delay
return 0;
}

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 the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS