Q1: Write a C program to print "Bigger number" out of the three?
Using nested if:
#include<conio.h>
#include<stdio.h>
void main()
{
//bigger number
int a=20,b=405,c=78;
clrscr();
if(a>b)
{
if(a>c)
{
printf("\nthe bigger no.=%d",a);
}
else
{
printf("\nthe bigger no.=%d",c);
}
}
else if(b>c)
{
printf("\nthe bigger no.=%d",b);
}
else
{
printf("\nthe bigger no.=%d",c);
}
getch();
}
Using && :
#include<conio.h>
#include<stdio.h>
void main()
{
//bigger number
int a=20,b=405,c=78;
clrscr();
if(a>b && a>c)
{
printf("\n\nthe bigger no.=%d",a);
}
else if(b>a && b>c)
{
printf("\n\nthe bigger no.=%d",b);
}
else
{
printf("\n\nthe bigger no.=%d",c);
}
getch();
}
***********************************************************************************
Sample Output:
Comments
Post a Comment
Thanks for the comment and don't forget to subscribe.