#include<stdio.h>
void main()
{
int a,b,c;
printf("Enter 3 numbers");
scanf("%d%d%d",&a,&b,&c);
if(a>b && a>c)
printf("Mximum number is a = %d",a);
else if(b>a && b>c)
printf("Mximum number is b = %d",b);
else
printf("Mximum number is c = %d",c);
if(a<b && a<c)
printf("Minimum number is a = %d",a);
else if(b<a && b<c)
printf("Minimum number is b = %d",b);
else
printf("Minimum number is c = %d",c);
}
15 comments: (+add yours?)
thanks bro..
Finally I got the solution but I also need a pseudo code of this problem.
What if I enter all three as same number.
I have not check yet..i think it will show you garbage value.
Great bro
Noop, it's working ✌
wrong code .If a=b then it always return c,means max and min
value will be same in that case.which is wrong
Nice Post. You cal also do this using command line arguments. Source code is here https://www.computerscienceai.com/2018/02/c-program-to-accept-three-integers-as.html
Great! It works! Thanks!
Show output
Show output
// If you dont want to reverse operator ..you can do like this solution :
#include
using namespace std;
void check(int a,int b, int c){
if((a>=b && a>=c)){
if(b=a && b>=c)){
if(a>a>>b>>c;
check(a,b,c);
return 0;
}
#include
int main()
{
int a1,a2,a3,max,min;
printf("enter value of a1, a2, a3\n");
scanf("%d%d%d",&a1,&a2,&a3);
if(a1a3)
{
max= a2;
}
else
{
max = a3;
}
}
else
{
min =a3;
max = a2;
}
}
else if(a2a3)
{
max =a1;
}
else
max = a3;
}
else
{ min =a3;
if(a2>a1)
{
max = a2;
}
else
max = a1;
}
printf(" maximum = %d\n",max);
printf(" minimum = %d\n",min);
return(0);
}
Show output plz
Try this
#include
int main()
{
int a, b, c,max,min;
printf("Enter three numbers\n");
scanf("%d%d%d", &a, &b, &c);
max= (a>b)&&(a>c)?a : (b>a)&&(b>c)?b : c;
printf("The maximum number: %d\n", max);
min = (a<b)&&(a<c)?a : (b<a)&&(b<c)?b : c;
printf("The minimum number: %d\n", min);
return 0;
}
Post a Comment