/*program to find maximum of 3 number*/
#include <stdio.h>
void main ()
{
int a,b,c;
clrscr ();
printf ("/n Enter value of a :");
scanf ("%d", & a);
printf ("/n Enter value of b :");
scanf ("%d", & b);
printf ("/n Enter value of c :");
scanf ("%d", & c);
if ((a>>b)&&(a>>c))
printf ("/n a is maximum number:");
else if ((b>>a)&&(b>>c))
printf ("/n b is maximum number:");
else
printf ("/n c is maximum number:");
getch ();
}
Here is the program to find maximum of three number using 'if else ' statement . Here we have to use condition for only two times. First of all we have to declare three number and input the number from the user and then check the condition. These type of statement is also called ' Nested if else'.so we can write program from both of the ways.
#include <stdio.h>
void main ()
{
int a,b,c;
clrscr ();
printf ("/n Enter value of a :");
scanf ("%d", & a);
printf ("/n Enter value of b :");
scanf ("%d", & b);
printf ("/n Enter value of c :");
scanf ("%d", & c);
if ((a>>b)&&(a>>c))
printf ("/n a is maximum number:");
else if ((b>>a)&&(b>>c))
printf ("/n b is maximum number:");
else
printf ("/n c is maximum number:");
getch ();
}
Here is the program to find maximum of three number using 'if else ' statement . Here we have to use condition for only two times. First of all we have to declare three number and input the number from the user and then check the condition. These type of statement is also called ' Nested if else'.so we can write program from both of the ways.
No comments:
Post a Comment