/* C program to find largest number using if...else statement */
#include <stdio.h>
#include<conio.h>
void main()
{
int a, b, c;
printf("Enter the values of a, b and c: ");
scanf("%d%d%d", &a, &b, &c);
if (a>b && a>c)
{
printf("A is largest number = %d",a);
}
if (b>a && b>c)
{
printf("B is largest number = %d",b);
}
if (c>a && c>b)
{
printf("C is largest number = %d",c);
}
getch();
}
OR
#include <stdio.h>
#include <conio.h>
int main()
{
int a, b, c;
printf("Enter a,b,c: ");
scanf("%d %d %d", &a, &b, &c);
if (a > b && a > c)
{
printf("a is Greater than b and c");
}
else if (b > a && b > c)
{
printf("b is Greater than a and c");
}
else if (c > a && c > b)
{
printf("c is Greater than a and b");
}
else
{
printf("all are equal or any two values are equal");
}
getch();
}
#include <stdio.h>
#include<conio.h>
void main()
{
int a, b, c;
printf("Enter the values of a, b and c: ");
scanf("%d%d%d", &a, &b, &c);
if (a>b && a>c)
{
printf("A is largest number = %d",a);
}
if (b>a && b>c)
{
printf("B is largest number = %d",b);
}
if (c>a && c>b)
{
printf("C is largest number = %d",c);
}
getch();
}
OR
#include <stdio.h>
#include <conio.h>
int main()
{
int a, b, c;
printf("Enter a,b,c: ");
scanf("%d %d %d", &a, &b, &c);
if (a > b && a > c)
{
printf("a is Greater than b and c");
}
else if (b > a && b > c)
{
printf("b is Greater than a and c");
}
else if (c > a && c > b)
{
printf("c is Greater than a and b");
}
else
{
printf("all are equal or any two values are equal");
}
getch();
}
No comments:
Post a Comment