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); }..

-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 ? 52 Yes 1 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 ? 7 Yes 2 No

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

Answer / mohamedsalman s

-1

 Is This Answer Correct ? 4 Yes 0 No

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

-1

 Is This Answer Correct ? 2 Yes 0 No

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

-1

 Is This Answer Correct ? 1 Yes 0 No

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

0

 Is This Answer Correct ? 1 Yes 1 No

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

i think it is -1

 Is This Answer Correct ? 0 Yes 1 No

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

1

 Is This Answer Correct ? 0 Yes 2 No

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

0

 Is This Answer Correct ? 2 Yes 10 No

More C Code Interview Questions

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

could you please send the program code for multiplying sparse matrix in c????

main() { int c=- -2; printf("c=%d",c); }

struct Foo { char *pName; }; main() { struct Foo *obj = malloc(sizeof(struct Foo)); clrscr(); strcpy(obj->pName,"Your Name"); printf("%s", obj->pName); } a. Your Name b. compile error c. Name d. Runtime error

write a c program to Create a registration form application by taking the details like username, address, phone number, email along with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 5 users and display the details. In place of password display “****”. (Use Structures).

char *someFun() { char *temp = “string constant"; return temp; } int main() { puts(someFun()); }

main() { char c=' ',x,convert(z); getc(c); if((c>='a') && (c<='z')) x=convert(c); printf("%c",x); } convert(z) { return z-32; }

int swap(int *a,int *b) { *a=*a+*b;*b=*a-*b;*a=*a-*b; } main() { int x=10,y=20; swap(&x,&y); printf("x= %d y = %d\n",x,y); }

Given n nodes. Find the number of different structural binary trees that can be formed using the nodes.

Write a procedure to implement highlight as a blinking operation

main() { int x=5; clrscr(); for(;x==0;x--) { printf("x=%d\n”", x--); } } a. 4, 3, 2, 1, 0 b. 1, 2, 3, 4, 5 c. 0, 1, 2, 3, 4 d. none of the above

void pascal f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } void cdecl f(int i,int j,int k) { printf(“%d %d %d”,i, j, k); } main() { int i=10; f(i++,i++,i++); printf(" %d\n",i); i=10; f(i++,i++,i++); printf(" %d",i); }

Categories