In this page you can see some examples on Control Structures
write a c Program accept three numbers and check which one of them is greatest by using if else
Solution:
#include<stdio.h>
main()
{
int a,b,c;
clrscr(); /* to clear the screen */
printf("\n Enter three numbers: ");
scanf("%d%d%d",&a,&b,&c);
if(a>b&&a>c)
printf("\n %d is greatest",a);
else
{
if(b>c)
printf("\n %d is greatest",b);
else
printf("\n %d is greatest",c);
}
getch();
}
output: Enter Three Numbers: 5 7 0
7 is greatest
No comments:
Post a Comment