943,718 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 2975
  • C RSS
Jul 13th, 2004
0

probem with code of conditional operators

Expand Post »
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.
:-|
Similar Threads
Reputation Points: 13
Solved Threads: 0
Newbie Poster
abd2 is offline Offline
3 posts
since Jul 2004
Jul 13th, 2004
0

Re: probem with code of conditional operators

Our friend scanf claims another victim.
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5. int x, min, max;
  6. printf("Enter val for max and x\n");
  7. scanf("%d%d",&max,&x);
  8. min = x > max ? max : x;
  9. printf("%d\n",min);
  10. return 0;
  11. }
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: modifying an exe
Next Thread in C Forum Timeline: problem about the codding





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC