I need help with the following questions
1)
Code:
int z,x=5,y=-10,a=4,b=2; z = x++ - --y * b / a;
output?
2)
Code:
int a=10,b;b=a++ + ++a;printf("%d,%d,%d,%d",b,a++,a,++a);
I felt the answer would be 21,13,13,13 but the answer is 22,13,13,13.How b is coming as 22?
3)
Code:
void myFunc (int x) { if (x > 0) myFunc(--x);
printf("%d, ", x); }
int main()
{ myFunc(5); return 0; }
I felt the answer should be 0, 1, 2, 3, 4, but is 0,0,1,2,3,4.How is the extra 0 coming?
4) why does 11 ^ 5 show 14
5) .here a should have been 13(5*2+3) but it is coming as 25.How?
6)
Code:
#include int i;
void increment( int i ) { i++; }
int main() {
for( i = 0; i < 10; increment( i ) )
{ }
printf("i=%d\n", i); return 0;
}
Why is this creating an infinite loop?