In this program, the input is being checked and for 3 numbers, there will be requirement of three variables so, "int a, b, c;" are assigned. Now, the variables assigned should be equal to zero initially, so that new values could be assigned by user itself. And so, the values are also being checked by if else statements.
Program to find the largest no. among 3 no.s
#include<stdio.h>#include<conio.h>
void main()
{ int a=0,b=0,c=0;
clrscr();
printf("\n program to find largest among 3 no.s");
printf("\n\n enter a : ");
scanf("%d",&a);
printf("enter b : ");
scanf("%d",&b);
printf("enter c : ");
scanf("%d",&c);
if((a>b) && (a>c))
{ printf("\n\n %d = a is greatest",a); }
if((b>a) && (b>c))
{ printf("\n\n %d = b is greatest",b); }
if((c>a) && (c>b))
{ printf("\n\n %d = c is greatest",c); }
getch();
}

No comments:
Post a Comment
Guys if you think something is wrong or should be edit than please do comment.