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.
:-|

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;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.