0

hi,
This is the code to be changed to conditional operators:
#include <stdio.h>
main()
{
int x, min, max;
printf("Enter val for max and x\n");
scanf("\n%d%d",&max,&x);
if(x>max)
min=max;
else
min=x;
printf("%d\n",min);

}


the above code is runing but problem is when changed to conditional operators:
#include <stdio.h>
main()
{
int x, min, max;
printf("Enter val for max and x\n");
scanf("\n%d%d\n",&max,&x);

min=(x>max ? max : x);
printf("\n%d\n",min);

}

then with:
$gcc -o la70 la70.c
there is no error but now when i am runing this ./la70 it is asking for the input then there is no output and when i hit <return>it is halting without any ouput as shown below:
[root@localhost lbin]# ./la70
Enter val for max and x
8 4

plz help me.
:-|

2
Contributors
1
Reply
2
Views
13 Years
Discussion Span
Last Post by Dave Sinkula
0

Our friend scanf claims another victim.

#include <stdio.h>
 
int main(void)
{
int x, min, max;
printf("Enter val for max and x\n");
scanf("%d%d",&max,&x);
min = x > max ? max : x;
printf("%d\n",min);
return 0;
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.