Page 1 of 1

PROJECT:- Find Greatest Number Between Three Numbers

Unread postPosted: Thu May 22, 2008 6:23 pm
by rajeevmahura
#include<stdio.h>
#include<conio.h>
void main()
{

int num1,num2,num3,great;
clrscr();
printf("Enter Any Numbers for num1,num2 and num3 ");
scanf("%d%d%d",&num1,&num2,&num3);

if(num1>num2>num3)
{
printf("Number %d is Greatest ",num1);
if(num1<num2>num3)
{
printf("Number %d is Greatest ",num2);
}
}
else
{
printf("Number %d is Greatest ",num3);
}
getch();
}
-------------------------------------------------------------
Input: num1=2,num2=4,num3=6
Output: Number 6 is Greatest

Re: PROJECT:- Find Greatest Number Between Three Numbers

Unread postPosted: Tue Sep 01, 2009 7:03 am
by manojthesingham
#include<stdio.h>
#include<conio.h>
/*
above algorithm is wrong:
check input 1 3 2
it prints 1 greater number
1>2>3=>
1>2=0
0>3=0
1>(2>3)
2>3=0
1>0=1
1>(3>2)
3>2=1
1>1=0
finding greatest of three numbers
is just like weighing objects in balance
*/
int main(int argc,char **argv)
{
int a,b,c;
printf("Input all the three numbers ");
scanf("%d",&a,printf("\nFirst : "));
scanf("%d",&b,printf("\nSecond : "));
scanf("%d",&c,printf("\nThird : "));
if(a>b)
{
if(a>c)
{
printf("\nA=%d is greater",a);
}
else
printf("\nC=%d is greater",c);
}
else
{
if(b>c)
printf("\nB=%d is greater",b);
else
printf("\nC=%d is greater",c);
}
getch();
return 1;
}