| | |
probem with code of conditional operators
![]() |
•
•
Join Date: Jul 2004
Posts: 3
Reputation:
Solved Threads: 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.
:-|
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.
C Syntax (Toggle Plain Text)
#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; }
"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
![]() |
Similar Threads
- Dynamic Operator (C#)
- Operators (C++)
- Conditional Expression (Python)
- void functions 3 (C++)
- how to test equality of 2 objects (C++)
- program for finding factorial of a number using *operator overloading (C++)
- unsigned/signed problem (C)
Other Threads in the C Forum
- Previous Thread: modifying an exe
- Next Thread: problem about the codding
| Thread Tools | Search this Thread |
#include adobe ansi api array asterisks binarysearch changingto char character cm copyimagefile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax database directory dynamic execv feet fgets file fork forloop frequency function getlasterror givemetehcodez global grade graphics gtkgcurlcompiling hacking hardware highest histogram i/o include incrementoperators infiniteloop input interest kernel keyboard kilometer license linked linkedlist linux linuxsegmentationfault list locate logical_drives looping loopinsideloop. lowest match matrix meter microsoft motherboard mqqueue mysql number odf opensource owf pattern pdf performance pointer posix probleminc process program programming radix recursion recv repetition research reversing scanf segmentationfault sequential shape socket socketprograming standard string systemcall threads turboc unix user voidmain() wab windows.h windowsapi






