PROJECT:- Find Greatest Number Between Three Numbers

Learn and Trouble Shoot Problems Related to C-Language here.

PROJECT:- Find Greatest Number Between Three Numbers

Unread postby rajeevmahura » Thu May 22, 2008 6:23 pm

#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
--Regards--
Rajeev Mahura
Servers & Storage Professional
http://about.me/rajeevmahura
User avatar
rajeevmahura
 
Posts: 144
Joined: Tue May 20, 2008 5:22 pm
Location: Bangalore | New Delhi
Full Name: Rajeev Mahura
Date Of Birth: 15 Jan 1984
Address: New Delhi
Profession: DOEACC Trainer
DOEACC Center: DOEACC DELHI
Mobile No: 0

Re: PROJECT:- Find Greatest Number Between Three Numbers

Unread postby manojthesingham » Tue Sep 01, 2009 7:03 am

#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;
}
If world is running, then I am idle..
If I am idle, then the world is running
User avatar
manojthesingham
 
Posts: 15
Joined: Tue Sep 01, 2009 5:39 am
Location: Coimbatore,Tamilnadu
Full Name: manoj
Date Of Birth: 31 Jul 1989
Address: Coimbatore18Tamilnadu
Mobile No: 0


Return to C-Language

Who is online

Users browsing this forum: No registered users and 1 guest

cron