//Write a program find largest of 3 no's using else– if .
#include < stdio.h >
#include < conio.h >
void main()
{
int a, b, c;
clrscr();
printf(“enter the values\ n”);
scanf(“ %d %d %d”, & a, & b, & c);
if (a = = b && b = = c)
{
printf(“values are equal”);
}
else if (a > b && a > c)
{
printf(“a is big\ n”);
}
else if (b > c)
{
printf(b is big\ n);
}
else
{
printf(“c is big\ n);
}
getch();
}
2. if..else statement
3. Nested if...else statement (if...else if....else Statement)
4. switch statement
example programs on if..else
#include < stdio.h >
#include < conio.h >
void main()
{
int a, b, c;
clrscr();
printf(“enter the values\ n”);
scanf(“ %d %d %d”, & a, & b, & c);
if (a = = b && b = = c)
{
printf(“values are equal”);
}
else if (a > b && a > c)
{
printf(“a is big\ n”);
}
else if (b > c)
{
printf(b is big\ n);
}
else
{
printf(“c is big\ n);
}
getch();
}
You may like the following posts:
1. if statement2. if..else statement
3. Nested if...else statement (if...else if....else Statement)
4. switch statement
example programs on if..else
No comments:
Post a Comment