954,505 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

probem with code of conditional operators

hi,
This is the code to be changed to conditional operators:
#include
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
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 it is halting without any ouput as shown below:
[root@localhost lbin]# ./la70
Enter val for max and x
8 4

plz help me.
:-|

abd2
Newbie Poster
3 posts since Jul 2004
Reputation Points: 13
Solved Threads: 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;
}
Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You