C program to print Largest and Second largest among Three numbers

#include<stdio.h>
#include<conio.h>
int main()
{
 clrscr();
 int a,b,c,l,s;
 printf("Enter three number\n");
 scanf("%d%d%d",&a,&b,&c);
 {
  if(a>b)
  l=a;
  else
  s=a;
  }
  if(b>c)
  {
  if(b>a)
  l=b;
  else
  s=b;
  }
  if(c>a)
  {
  if(c>b)
  l=c;
  else
  s=c;
  }
  printf("Largest among three number=%d",l);
  printf("\n");
  printf("Second largest number=%d",s);
  getch();
  return 0;
  }

Post a Comment

0 Comments