Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Wednesday, February 9, 2011

C3 : Find largest from given numbers


Back to Home   &  C


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...:) )


Back to Home   &  C

No comments: