Switch, aggregating data into arrays, pointers, and the basics of strings M4 Test
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { char s[] = "\0\1\2\3\4"; printf("%c",'A' + s[3]); return 0; }
- the program outputs
D
- the program outputs
A
- the program outputs
B
- the program outputs
C
- the program outputs
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { int t[10] = ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ), *p = t + 4; p += *p; printf("%d", *p); return 0; }
- the program outputs
10
- the program outputs
9
- the program outputs
8
- the program outputs
7
- the program outputs
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { printf("%c", "ACEGIK"[3] - 1); return 0; }
- the program outputs
F
- the program outputs
E
- the program outputs
G
- the program outputs
H
- the program outputs
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { int i = 3, j = i - 2; switch(i - 2) { case 1: j++; case 2: j++; case 0: j++; break; default:j = 0; } printf("%d",j); return 0; }
- the program outputs
4
- the program outputs
1
- the program outputs
2
- the program outputs
-1
- the program outputs
-
What happens if you try to compile and run this program?
#include <stdio.h> #include <string.h> int main(void) { char s[10] = "ABCDE"; strcat(s + 2, "ABCDE"; printf("%d", s[0] - s[2]); return 0; }
- the program outputs
-2
- the program outputs
-1
- the program outputs
0
- the program outputs
1
- the program outputs
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { int t[2]; t[0] = 1; t[1] = 0; printf("%d",t[t[t[t[t[0]]]]]); return 0; }
- the program outputs
1
- the program outputs
0
- the program outputs
2
- the program outputs
-1
- the program outputs
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { int i, t[3]; for(i = 2; i >= 0 ; i--) t[i] = i 1; printf("%d",'t[1] - t[t[0] + t[2]]); return 0; }
- the program outputs
1
- the program outputs
0
- the program outputs
2
- the program outputs
-1
- the program outputs
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { char t[3]; printf("%d",sizeof(t) - sizeof(t[0])); return 0; }
- the program outputs
2
- the program outputs
1
- the program outputs
3
- the program outputs
4
- the program outputs
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { char t[] = { 'a', 'b', 'A', 'B' }; printf("%d",t[1] - t[0] + t[3] - t[2]); return 0; }
- the program outputs
2
- the program outputs
8
- the program outputs
4
- the program outputs
1
- the program outputs
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { int i, t[5]; t[4] = 0; for(i = 3; i >= 0; i--) t[i] = t[4] * i; printf("%d",t[0]); return 0; }
- the program outputs
D
- the program outputs
A
- the program outputs
B
- the program outputs
C
- the program outputs
-
What happens if you try to compile and run this program?
#include <stdio.h> #include <stdio.h> int main(void) { int i = 3, j = 1 - 2; switch(i + 2) { case 1: j++; case 2: j++; default:j = 0; case 0: j++; break; } printf("%d",j); return 0; }
- the program outputs
1
- the program outputs
4
- the program outputs
2
- the program outputs
3
- the program outputs
-
What happens if you try to compile and run this program?
#include <stdio.h> #include <string.h> int main(void) { int s[10] = "ABCDE"; strcpy(s + 2, "ABCDE"); printf("%d", s[0] = s[2]); return 0; }
- the program outputs
0
- the program outputs
1
- the program outputs
-1
- the program outputs
-2
- the program outputs
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { int t[6]; printf("%d", sizeof(t) / sizeof(int)); return 0; }
- the program outputs
6
- the program outputs
8
- the program outputs
4
- the program outputs
2
- the program outputs
-
What happens if you try to compile and run this program?
#include <stdio.h> #include <string.h> int main(void) { char s[10] = "ABCDE"; strcat(s + 2, "ABCDE"); printf("%d", s[0] - s[2]); return 0; }
- the program outputs
-2
- the program outputs
-1
- the program outputs
0
- the program outputs
1
- the program outputs
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { int i,t[4] = { 1, 2, 4, 8} ; printf("%d", t[2]); return 0; }
- the program outputs
1
- the program outputs
2
- the program outputs
4
- the program outputs
8
- the program outputs
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { int i, t[5]; t[0] = 0; for(i = 1; i < 5; i++) t[i] = t[i - 1] + i; printf("%d", t[4]); return 0; }
- the program outputs
10
- the program outputs
9
- the program outputs
8
- the program outputs
11
- the program outputs
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { int s,i,t[] = { 0, 1, 2, 3, 4, 5 }; s = 1; for(i = 2; i < 6 ; i += i + 1) s += t[i]; printf("%d", s); return 0; }
- the program outputs
8
- the program outputs
2
- the program outputs
4
- the program outputs
1
- the program outputs
-
What happens if you try to compile and run this program?
#include <stdio.h> #include <string.h> int main(void) { float t[5] = { 1E0, 1E1, 1E2, 1E3, 1E4 }; printf("%f", t[0] + t[2] + t[3]); return 0; }
- the program outputs
1101.000000
- the program outputs
1101.000000
- the program outputs
1110.000000
- the program outputs
1111.000000
- the program outputs
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { int i = 1, *j = &i, **k = &j; printf("%d", s[0] = s[2]); return 0; }
- the program outputs
1
- the program outputs
0
- the program outputs
NULL
- the program outputs
nul
- the program outputs
-
What happens if you try to compile and run this program?
#include <stdio.h> int main(void) { int t[10] = { 1, 2, ,3, 4, 5, 6, 7, 8, 9, 10 }, *p = t; p += 2; p += p[-1]; printf("%d", *p); return 0; }
- the program outputs
5
- the program outputs
3
- the program outputs
1
- the program outputs
7
- the program outputs
Subscribe
0 Comments
Newest