This is program to find maximum number between three number in C in which first of all declare three variable at the starting of the program and then input three number from the user and after that we have write conditions for checking the maximum of three variable.
/* 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:");
if ( (b>a) && (b>c) )
printf ("/n b is maximum number:");
if ( (c>a) && (c>b) )
printf ("/n c is maximum number:");
getch();
}
Here we use condition for checking that input number is maximum or not but we can also made this program with the help of ' if else ' statement in using with two condition.
/* 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:");
if ( (b>a) && (b>c) )
printf ("/n b is maximum number:");
if ( (c>a) && (c>b) )
printf ("/n c is maximum number:");
getch();
}
Here we use condition for checking that input number is maximum or not but we can also made this program with the help of ' if else ' statement in using with two condition.
A very useful site, which I will bear in mind for future reference, Alan
ReplyDelete