-
What happens if you try to compile and run this program?
#include <stdio.h>
int f(int t[][]) {
return t[0][0] + t[1][0];
}
int main(void)
{
int i,a[2][2] = { {-2, -1}, {1,2} };
i = f(a + 2);
printf("%d", i);
return 0;
}
- the program outputs
0
- the program outputs
2
- the compilation fails
- the program outputs
1
-
What happens if you try to compile and run this program?
#include <stdio.h>
int i = 0;
int *f(int *i) {
(*i)++;
return i;
}
int main(void) {
int i = 1;
i = *f(&i);
printf("%d", i);
return 0;
}
- the program outputs
2
- the program outputs
1
- the compilation fails
- the program outputs
0
-
What happens if you try to compile and run this program?
#include <stdio.h>
#include <string.h>
struct Q {
chart s[3];
};
struct S {
struct Q Q;
};
int main(void) {
struct S S = { '\0', '\0','\0'};
S.Q.S[0] = 'A';
S.Q.S[1] = 'B';
printf("%d",strlen(S.Q.S);
return 0;
}
- the program outputs
2
- the program outputs
4
- the program outputs
3
- the program outputs
1
-
What happens if you try to compile and run this program?
#include <stdio.h>
struct S {
int a[2];
};
int main(void) {
struct S S[2];
int i;
for(i = 0; i < 2; i++;
S[i].a[1-i] = 4 * !i;
printf("%d",S[0].a[1]);
return 0;
}
- the program outputs
3
- the program outputs
4
- the program outputs
2
- the program outputs
1
-
What happens if you try to compile and run this program?
#include <stdio.h>
int i = 2;
int *f(void) {
return &i;
}
int main(void) {
int *i;
i = f();
printf("%d",++(*i));
return 0;
}
- the program outputs
1
- the compilation fails
- the program outputs
3
- the program outputs
2
-
What happens if you try to compile and run this program?
#include <stdio.h>
#include <stdlib.h>
struct S {
int a;
struct S *b;
};
int main(void) {
struct S *x = malloc(sizeof(struct S));
struct S *y = malloc(sizeof(struct S));
x >a = 2;
x >b = y;
y >a = 4;
y >b = x;
printf("%d",x->b->b->b->a);
free(x); free(y);
return 0;
}
- the program outputs
3
- the program outputs
4
- the program outputs
2
- the program outputs
1
-
What happens if you try to compile and run this program?
#include <stdio.h>
#include <string.h>
void f(char *s,int i) {
*(s + i) = '\0';
}
int main(void) {
char a[] = { 'a','b','c','d' };
f(a+1,1);
printf("%d",strlen(a));
return 0;
}
- the program outputs
1
- the program outputs
0
- the compilation fails
- the program outputs
2
-
What happens if you try to compile and run this program?
#include <stdio.h>
#include <stdlib.h>
struct S {
int a;
struct S *b;
}
int main(void) {
struct S *x = malloc(sizeof(struct S));
struct S *y = malloc(sizeof(struct S));
struct S *p;
x-> = 2; x->b = y;
y-> = 4; y->b = x;
p = x;
p = p >b->b->b->b;
printf("%d", p >a);
return 0;
}
- the program outputs
3
- the program outputs
1
- the program outputs
2
- the program outputs
4
-
What happens if you try to compile and run this program?
#include <stdio.h>
int i = 1;
int *f(void) {
return &i;
}
int main(void) {
int i = 0;
i = *f();
printf("%d", i);
return 0;
}
- the program outputs
2
- the program outputs
1
- the compilation fails
- the program outputs
0
-
What happens if you try to compile and run this program?
#include <stdio.h>
struct S {
char *p;
};
int main(void) {
char *p = "abcd";
struct S S[2];
int i;
for(i = 0; i < 2; i++)
S[i].p = p + i;
printf("%d",S[1].p[0]);
return 0;
}
- the program outputs
a
- the program outputs
b
- the program outputs
c
- the program outputs
d
-
What happens if you try to compile and run this program?
#include <stdio.h>
int f(int t[]) {
return t[0] + t[2];
}
int main(void) {
int i,a[] = { -2,-1,0,1,2 };
i = f(a + 2);
printf("%d", i);
return 0;
}
- the program outputs
0
- the program outputs
1
- the program outputs
2
- the compilation fails
-
What happens if you try to compile and run this program?
#include <stdio.h>
Struct S {
int S;
};
int f(struct S *s) {
return --s.S;
}
int main(void) {
int i;
struct S S = { 2 };
i = f(S);
printf("%d", i);
return 0;
}
- the program outputs
1
- the program outputs
2
- the program outputs
0
- the compilation fails
-
What happens if you try to compile and run this program?
#include <stdio.h>
struct S {
int S;
};
int main(void) {
struct S S;
S.S = sizeof(struct S) / sizeof(S));
printf("%d", S.S);
return 0;
}
- the program outputs
1
- the program outputs
2
- the program outputs
3
- the program outputs
4
-
What happens if you try to compile and run this program?
#include <stdio.h>
#include <string.h>
struct Q {
char S[3];
};
struct S {
struct Q Q;
};
int main(void) {
struct S S = { '\0', '\0','\0' };
S.Q.S[0] = 'A';
S.Q.S[2] = 'B';
printf("%d",strlen(S.Q.S));
return 0;
}
- the program outputs
1
- the program outputs
2
- the program outputs
4
- the program outputs
3
-
What happens if you try to compile and run this program?
#include <stdio.h>
struct Q {
int a,b,c;
};
struct S {
int a,b,c;
struct Q Q;
};
int main(void) {
struct Q Q = { 3,2,1 };
struct S S = { 4,5,6 };
S.Q = Q;
printf("%d",S.b - S.Q.b);
return 0;
}
- the program outputs
3
- the program outputs
2
- the program outputs
4
- the program outputs
3
-
What happens if you try to compile and run this program?
#include <stdio.h>
int f(char t[]) {
return t[1] - t[0];
}
int main(void) {
int i = 2;
i -= f("ABDGK" + 1);
printf("%d",i);
return 0;
}
- the compilation fails
- the program outputs
0
- the program outputs
1
- the program outputs
2
-
What happens if you try to compile and run this program?
#include <stdio.h>
int f(char t[]) {
return t[0] - t[-1];
}
int main(void) {
int i = 2;
i -= f("ABDGK" + 1);
printf("%d",i);
return 0;
}
- the program outputs
1
- the compilation fails
- the program outputs
-1
- the program outputs
0
-
What happens if you try to compile and run this program?
#include <stdio.h>
struct S {
int S;
};
int f(struct S s) {
return --s.S;
}
int main(void) {
int i;
struct S S = { 2 };
i = f(S);
printf("%d",i);
return 0;
}
- the program outputs
0
- the program outputs
1
- the program outputs
2
- the compilation fails
-
What happens if you try to compile and run this program?
#include <stdio.h>
#include <string.h>
void f(char *s,int i) {
*(s + i) = '\0';
}
int main(void) {
char a[] = { 'a','b','c','d' };
f(a[1],1);
printf("%d",strlen(a));
return 0;
}
- the program outputs
2
- the compilation fails
- the program outputs
1
- the program outputs
0
-
What happens if you try to compile and run this program?
#include <stdio.h>
#include <string.h>
struct Q {
char S[3];
};
struct S {
struct Q Q;
};
int main(void) {
struct S S = { '\0', '\0','\0' };
S.Q.S[0] = 'A';
S.Q.S[2] = 'B';
printf("%d",strlen(S.Q.S));
return 0;
}
- the program outputs
1
- the compilation fail
- the program outputs
2
- the program outputs
1