main()
{
int i=10,j=20;
j = i, j?(i,j)?i:j:j;
printf("%d %d",i,j);
}
Answers were Sorted based on User's Feedback
Answer / susie
Answer :
10 10
Explanation:
The Ternary operator ( ? : ) is equivalent for
if-then-else statement. So the question can be written as:
if(i,j)
{
if(i,j)
j = i;
else
j = j;
}
else
j = j;
| Is This Answer Correct ? | 67 Yes | 11 No |
Answer / sweksha
#include<stdio.h>
#include<conio.h>
void main()
{ int i,k;
clrscr();
i=0; k=10;
k=i,k?(i,k)?k:k:i; //i is assigned to k
printf("\n%d %d",i,k);//0 0
i=0; k=10;
k=(i,k)?(i,k)?k:i:i; //(0,10) is T so k=k
printf("\n%d %d",i,k);//0 10
i=0; k=10;
k=(k,i)?(i,k)?k:k:i; //(10,0) is F so k=i
printf("\n%d %d",i,k); //0 0
i=0; k=10;
k=k,i?(i,k)?k:i:k; //k is assigned to k
printf("\n%d %d",i,k);//0 10
i=0; k=10;
k=(i,k)?(k,i)?k:i:k; //(0,10) is T and (10,0) is F so k=i
printf("\n%d %d",i,k);//0 0
getch();
}
| Is This Answer Correct ? | 3 Yes | 1 No |
# include<stdio.h> aaa() { printf("hi"); } bbb(){ printf("hello"); } ccc(){ printf("bye"); } main() { int (*ptr[3])(); ptr[0]=aaa; ptr[1]=bbb; ptr[2]=ccc; ptr[2](); }
program to find the roots of a quadratic equation
14 Answers College School Exams Tests, Engineering, HP, IIIT, Infosys, Rajiv Gandhi University of Knowledge Technologies RGUKT, SSC,
main() { float me = 1.1; double you = 1.1; if(me==you) printf("I love U"); else printf("I hate U"); }
What is the problem with the following code segment? while ((fgets(receiving array,50,file_ptr)) != EOF) ;
main() { while (strcmp(“some”,”some\0”)) printf(“Strings are not equal\n”); }
void main() { printf(“sizeof (void *) = %d \n“, sizeof( void *)); printf(“sizeof (int *) = %d \n”, sizeof(int *)); printf(“sizeof (double *) = %d \n”, sizeof(double *)); printf(“sizeof(struct unknown *) = %d \n”, sizeof(struct unknown *)); }
main() { extern out; printf("%d", out); } int out=100;
void main() { char ch; for(ch=0;ch<=127;ch++) printf(“%c %d \n“, ch, ch); }
write the function. if all the character in string B appear in string A, return true, otherwise return false.
main() { int i; printf("%d",scanf("%d",&i)); // value 10 is given as input here }
main(){ char a[100]; a[0]='a';a[1]]='b';a[2]='c';a[4]='d'; abc(a); } abc(char a[]){ a++; printf("%c",*a); a++; printf("%c",*a); }
main() { int a[10]; printf("%d",*a+1-*a+3); }