Hi i'm trying to study for c programming course midterm and there are few questions i have no idea why the answer is. could anyone describe why the answer comes out like these?
#include <stdio.h>
int main(){
int i = 3;
if (((i+=3)&&(i++>6))||((++i>8)&&(i+=3)))
printf("Yes. i is %d",i);
else
printf("No. i is %d",i);
return 0;
}
the answer for this code is "No. i is 8"
the second code is:
#include <stdio.h>
int main(){
int i, a[6];
for(i=0;i++<5;) a[i] = i*10;
for(--i;--i>0;)
printf("%d - %d \n",i,a[i]);
return 0;
}
and the answer to this code is:
4 - 40
3 - 30
2 - 20
1 - 10
the third code is:
#include<stdio.h>
#define printmax(x,y) printf("the max of %d and %d is",x,y); printf("%d\n",(x > y ? x: y))
int main(){
int i = 5, j = 10;
printmax((i++),(j++));
printf("i = %d, j = %d",i,j);
return 0;
}
and the answer to this code is:
the max of 5 and 10 is 12
i = 7, j = 13
i'm not very experienced with C programming and so i'm trying to understand but i just can't :(((