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



main() { int i=10,j=20; j = i, j?(i,j)?i:j:j; printf("%d %d",..

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

main() { int i=10,j=20; j = i, j?(i,j)?i:j:j; printf("%d %d",..

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

Post New Answer

More C Code Interview Questions

#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }

2 Answers  


pls anyone can help me to write a code to print the values in words for any value.Example:1034 to print as "one thousand and thirty four only"

2 Answers  


prog. to produce 1 2 3 4 5 6 7 8 9 10

4 Answers   TCS,


Is this code legal? int *ptr; ptr = (int *) 0x400;

1 Answers  


What is the output for the following program main() { int arr2D[3][3]; printf("%d\n", ((arr2D==* arr2D)&&(* arr2D == arr2D[0])) ); }

1 Answers  






respected sir, i did my MCA in 2013 when i am going to attend to an interview i was asked about my project how will i explain my project could please help me in this and my project title is "Social Networking Site For Social Responsibility"

1 Answers   Genpact, Ozdocs,


main() { int i =10, j = 20; clrscr(); printf("%d, %d, ", j-- , --i); printf("%d, %d ", j++ , ++i); } a. 20, 10, 20, 10 b. 20, 9, 20, 10 c. 20, 9, 19, 10 d. 19, 9, 20, 10

4 Answers   HCL,


#include<stdio.h> main() { struct xx { int x=3; char name[]="hello"; }; struct xx *s; printf("%d",s->x); printf("%s",s->name); }

3 Answers   Hexaware,


void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); }

2 Answers  


#include<stdio.h> main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d..%d",*p,*q); }

1 Answers  


PROG. TO PRODUCE 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1

1 Answers  


Sorting entire link list using selection sort and insertion sort and calculating their time complexity

1 Answers   Infosys, Microsoft, NetApp,


Categories