probem with code of conditional operators

Reply

Join Date: Jul 2004
Posts: 3
Reputation: abd2 is an unknown quantity at this point 
Solved Threads: 0
abd2 abd2 is offline Offline
Newbie Poster

probem with code of conditional operators

 
0
  #1
Jul 13th, 2004
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.
:-|
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,358
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 237
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: probem with code of conditional operators

 
0
  #2
Jul 13th, 2004
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. }
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC