Solution to Midterm Exam
2. What is printed?
#define VAL 4
#include <stdio.h>
main()
{
int a[3];
a[0] = 1;
a[1] = -1;
a[2] = VAL;
printf("%d\n", a[0] < 1 || a[1] != 1);
printf("%d\n", !a[1]);
printf("%d\n", a[0] | a[1]);
printf("%d\n", a[a[0]+1]);
}
1
0
-1
4
Previous slide
Next slide
Back to first slide
View graphic version