Solution for Exercise 8-13
ex0813
#include <stdio.h>
int main()
{
int first,second;
printf("Input the first value: ");
scanf("%d",&first);
printf("Input the second value: ");
scanf("%d",&second);
puts("Evaluating...");
if(first<second)
{
printf("%d is less than %d\n",first,second);
}
else if(first>second)
{
printf("%d is greater than %d\n",first,second);
}
else
{
printf("%d is equal to %d\n",first,second);
}
return(0);
}
Output
Input the first value: 256
Input the second value: 0
Evaluating...
256 is greater than 0
Notes
* The condition remaining for the final else part of the structure is == (is equal to). That's expressed by the printf() statement at Line 23. You could specify that condition with another else if, but it's not necessary.
Copyright © 1997-2025 by QPBC.
All rights reserved
