Anonymous

How To Create A Program That Print The Highest Value Among 3 Input Numbers?

2

2 Answers

Gulzar A Laskar Profile
Gulzar A Laskar answered
/* program to print the highest value among three input numbers*/

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
printf("Enter three values");
scanf("%d%d%d", &a,&b,&c);

if(a>b && b>c)
printf(" a=%d is highest value", a);
else if(b>a && b>c)
printf("b=%d is the highest value",b);
else
printf(c=%d is the highest value",c);
getch();
}
thanked the writer.
Anonymous
Anonymous commented
//this code is optimized and will take minimum time to run and give the result because it has the minimum condition to be compared

#include
#include
void main()
{
clrscr();
int a;
int b;
int c;
a=10;
b=20;
c=30;

if(a>b)
{
if(b>c)
{
printf("a");
}
else if(a>c)
{
printf("a");
}

}
else if(b>c)
{
printf("b");
}
else
{
printf("c");
}
getch();
}
Alongbar Daimary Profile
//Here is your Program. But I've not compiled it. Wrote directly here.
#include<iostream.h>
#include<conio.h>
void main(){
int Number[3];
cout<<"Enter three numbers";
for (int I=0;I<3;I++)
cin>>Number[I];

int Big=0;
for(int j=0;j<3;j++){
if (Big<Number[I])
Big=Number[I];
}
cout<<"Highest Number:"<<Big;
getch();
}

Answer Question

Anonymous