main()

{

int i=0;

while(+(+i--)!=0)

i-=i++;

printf("%d",i);

}

Answers were Sorted based on User's Feedback



main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }..

Answer / susie

Answer :

-1

Explanation:

Unary + is the only dummy operator in C. So it has no effect
on the expression and now the while loop is, while(i--!=0)
which is false and so breaks out of while loop. The value –1
is printed due to the post-decrement operator.

Is This Answer Correct ?    73 Yes 2 No

main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }..

Answer / govind verma

output will be -1.... because inwhile +(+i--)!=0 () have higher precedence then control goes to in parenthses and unary plus and ++ have the same precedece in table then we chek the associativty which is right to left i++ is evaluate first then the value of i will not chang withn a same expression because its a post fix increment now expression become +(+0)!=0 and unary plus have no effect then expression look lyk 0!=0 this condition is false then while block of code will not execute and nw i become -1 and we try to print like this printf("%d",-1); then output will -1

Is This Answer Correct ?    9 Yes 2 No

main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }..

Answer / mohamedsalman s

-1

Is This Answer Correct ?    6 Yes 0 No

main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }..

Answer / lavanya

-1

Is This Answer Correct ?    4 Yes 0 No

main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }..

Answer / venkatesh

-1

Is This Answer Correct ?    1 Yes 0 No

main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }..

Answer / babu

1

Is This Answer Correct ?    2 Yes 2 No

main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }..

Answer / ram

i think it is -1

Is This Answer Correct ?    1 Yes 1 No

main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }..

Answer / prem

0

Is This Answer Correct ?    1 Yes 6 No

main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }..

Answer / akshata

0

Is This Answer Correct ?    2 Yes 11 No

Post New Answer

More C Code Interview Questions

int main() { int x=10; printf("x=%d, count of earlier print=%d", x,printf("x=%d, y=%d",x,--x)); getch(); } ================================================== returns error>> ld returned 1 exit status =================================================== Does it have something to do with printf() inside another printf().

1 Answers  


In the following pgm add a stmt in the function fun such that the address of 'a' gets stored in 'j'. main(){ int * j; void fun(int **); fun(&j); } void fun(int **k) { int a =0; /* add a stmt here*/ }

1 Answers  


Which version do you prefer of the following two, 1) printf(“%s”,str); // or the more curt one 2) printf(str);

1 Answers  


int i; main(){ int t; for ( t=4;scanf("%d",&i)-t;printf("%d\n",i)) printf("%d--",t--); } // If the inputs are 0,1,2,3 find the o/p

2 Answers  


main() { while (strcmp(“some”,”some\0”)) printf(“Strings are not equal\n”); }

1 Answers  






main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }

9 Answers   CSC, GoDB Tech, IBM,


how to programme using switch statements and fuctions, a programme that will output two even numbers, two odd numbers and two prime numbers of the users chioce.

0 Answers   Mbarara University of Science and Technology,


main( ) { static int a[ ] = {0,1,2,3,4}; int *p[ ] = {a,a+1,a+2,a+3,a+4}; int **ptr = p; ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *ptr++; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); *++ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); ++*ptr; printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr); }

2 Answers   Persistent,


program to find magic aquare using array

4 Answers   HCL,


write a c program to Create employee record by taking details like name, employee id, address and phone number. While taking the phone number, take either landline or mobile number. Ensure that the phone numbers of the employee are unique. Also display all the details

2 Answers   TCS,


main() { int i = 258; int *iPtr = &i; printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) ); }

1 Answers  


void main() { while(1){ if(printf("%d",printf("%d"))) break; else continue; } }

1 Answers  


Categories