Write
a program in C to input three numbers from the user and print the maximum
number using if else statement.
Before going
through the program, we should know about if else statement. If else statement is
condition control statement which comes under control statement. It helps in
the flow of execution of program.
Let’s us
look through the syntax of if else statement.
If (condition)
{
Statement 1;
Else if
(condition)
Statement 2;
Else
Statement 3;
}
Program: -
#include<stdio.h>
Void main()
{
Int a, b, c;
Clrscr ();
Printf(“\n
enter the first number=”);
Scanf(“%d”,
& a);
Printf (“\n
enter the second number=”);
Scanf (“%d”,&b);
Printf(“\n
enter the third number=”);
Scanf( “%d”,&
c);
If( (a>b)
&& (b>c) )
Printf ( “%d
is a greatest number “, a);
Else if (
(b>c) && (b>a) )
Print ( “ %d
is a greatest number “, b);
Else
Printf ( “%d
is a greatest number “,c);
getch();
}
Enter the first number=
Enter the second number=
Enter the third number=
___ is the greatest number.
Comments
Post a Comment