A )))//To find largest from 3 numbers
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
float a,b,c;
printf("Enter 3 numbers\n");
scanf("%f%f%f",&a,&b,&c);
if(a>b)
{
if(a>c)
{
printf("%f is large",a);
}
else
{
printf("%f is large",c);
}
}
else
{
if(b>c)
{
printf("%f is large",b);
}
else
{
printf("%f is large",c);
}
}
getch();
}
---------------------------------------------------------
Output
Enter 3 numbers (Enter any 3 numbers as per your choice)
1
2
3
3 is large.
===============================================
B )))//To find largest from 2 numbers ( If-Else)
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
float a,b;
printf("Enter 2 numbers\n");
scanf("%f%f",&a,&b);
if(a>b)
{
printf("Largest no is %f",a);
}
else
{
printf("Largest no is %f",b);
}
getch();
}
---------------------------------------------------------
Output
Enter 2 numbers ( As per your choice)
5
8
Largest number is 8
===============================================
C )))//To find largest from n numbers
(Homework...:) )
(Homework...:) )
No comments:
Post a Comment