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 / furquan

Here what happens is :

while(+(+i--)!=0)
i = 0
so 0 != 0 is false hence condition for while fails. Now
there is also a post decrement operator. So value of i turns
out to be -1. and that is which is printed.

Is This Answer Correct ?    6 Yes 0 No

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

Answer / rameshp

ans s -1

Bec

while(1!=0) this s false..so next line don't exec..

so i-- means 0--= -1

finally we get -1

Is This Answer Correct ?    6 Yes 1 No

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

Answer / priyadarshan kasta

-1.


i don't know why.

plz post the reason

Is This Answer Correct ?    3 Yes 1 No

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

Answer / rayan

ans is -1.

Initially i == 0, when it enters into while loop

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

in 1st iteration i value ll be 0 only due to post decrement
operator.

in second iteration as i gets its post decremented value n
becomes -1 & -1 ~= 0 condition gets true & while loop breaks.

here + operator in the loop is doing ntg.

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More C Interview Questions

where can function pointers be used?

2 Answers  


find the sum of two matrices and WAP for it.

0 Answers   Huawei,


A function 'q' that accepts a pointer to a character as argument and returns a pointer to an array of integer can be declared as: A)int (*q(char*)) [] B)int *q(char*) [] C)int(*q)(char*) [] D)None of the Above

2 Answers   Accenture,


write a program to find the largest and second largest integer from an array

2 Answers   Value Labs,


write a program to find out prime number using sieve case?

0 Answers   HCL,






In header files whether functions are declared or defined?

1 Answers   TCS,


What is hashing in c?

0 Answers  


prog for 1st five prime numbers in 2^x - 1

0 Answers  


On most computers additional memory that is accessed through an adapter of feature card along with a device driver program. a) user memory b) conventional memory c) expandedmemory d) area

0 Answers  


why TCS selected more student in the software field from all institution.

5 Answers   TCS,


Why do we use null pointer?

0 Answers  


Write a program to identify if a given binary tree is balanced or not.

0 Answers   JPMorgan Chase,


Categories