Friday, April 10, 2015

27. Write a program that reads three numbers and displays the largest among them.

#include<stdio.h>
#include<conio.h>
void main()
{
int first,second,third;
clrscr();
printf("\n Input first number:-");
scanf("%d",&first);
printf("\n Input second number:-");
scanf("%d",&second);
printf("\n Input third number:- ");
scanf("%d",&third);
if(first>second)
{
if(first>third)
printf("\n %d is largest number",first);
else
printf("\n %d is largest number",third);
}
else
{
if(second>third)
printf("\n %d is largest number",second);
else
  printf("\n %d is largest number",third);
}
getch();
}

No comments:

Post a Comment