A C program to find the largest of three numbers;
#include <stdio.h>
int main()
{
int a,b,c;
printf("Enter first number ");
scanf("%d",&a);
printf("Enter second number ");
scanf("%d",&b);
printf("Enter third number ");
scanf("%d",&c);
if(a>b)
{
if(a>c)
printf("First is largest\n");
}
else
{
if(b>c)
printf("Second is largest\n");
else
printf("Third is largest\n");
}
return 0;
}
#include <stdio.h>
int main()
{
int a,b,c;
printf("Enter first number ");
scanf("%d",&a);
printf("Enter second number ");
scanf("%d",&b);
printf("Enter third number ");
scanf("%d",&c);
if(a>b)
{
if(a>c)
printf("First is largest\n");
}
else
{
if(b>c)
printf("Second is largest\n");
else
printf("Third is largest\n");
}
return 0;
}
No comments:
Post a Comment