25 câu hỏi
What is output? void main() { int i = 5, k; if (i == 0) goto label; label: printf("%d", i); printf("Hey"); getch(); }
Hey
5
5Hey
Complie error
What is output? void main() { printf("%d ", 1); goto l1; printf("%d ", 2); l1:goto l2; printf("%d ", 3); l2:printf("%d ", 4); getch(); }
1 4
1 2 3 4
Syntax error
Syntax error
What is output? #include #include void foo(); int main() { printf("%d ", 1); goto l1; printf("%d ", 2); } void foo() { l1: printf("3 "); }
Complie error
3
1
1 3
What is output? #include #include int main() { int i = 0, j = 0; while (i < 2) { l1: i++; while (j < 3) { printf("loop\n"); goto l1; } } getch(); }
>
loop loop loop
Infinite loop
Complie error
What is output? void main() { int a = 15, b = 10, c = 5; if(a > b > c) printf("True"); else printf("False"); getch(); }
True
False
Complier Error
Run time error
What is output? #include #include void main() { int i = 0; switch (i) { case '0': printf("A"); break; case '1': printf("B"); break; default: printf("ABC"); } getch(); }
A
B
ABC
What is output? #include #include "conio.h" void main() { int i = 3; switch (i) { case 0+1: printf("A"); break; case 1+2: printf("B"); break; default: printf("ABC"); } getch(); }
A
B
ABC
What is output? #include #include #define A 0 #define B 1 int main() { int i = 3; switch (i & 1) { case A: printf("FALSE"); break; case B: printf("TRUE"); break; default: printf("Default"); } getch(); }
FALSE
TRUE
Default
What is output? #include #include int main() { int i; if (printf("0")) i = 3; else i = 5; printf("%d", i); getch(); }
3
5
03
05
What is output? #include #include int main() { int a = 5; switch(a) { default: a = 4; case 6: a--; case 5: a = a + 1; case 1: a = a - 1; } printf("%d \n", a); getch(); }
3
4
5
6
What is output? #include #include int main() { int x = 3; if (x == 2); x = 0; if (x == 3) x++; else x += 2; printf("x = %d", x); getch(); }
x = 2
x = 6
x = 0
What is output? #include #include int main() { int check = 20, arr[] = {10, 20, 30}; switch (check) { case arr[0]: printf("A "); case arr[1]: printf("B"); case arr[2]: printf("C"); } getch(); }
ABC
BC
B
Complier Error
What is output of code? void main() { if ((1 || 0) && (0 || 1)) { printf("ABC"); } else { printf("DEF"); } getch(); }
ABC
DEF
Syntax error
What is output of code? #include #include #include void main() { char str1[] = "vncoding"; char str2[] = "vncoding"; if (strcmp(str1, str2)) printf("Equal"); else printf("Unequal"); getch(); }
Equal
Unequal
nothing is printed
What is output of code? #include #include void main() { int i; i = 10; if(i == 20 || 30) printf("True"); else printf("False"); getch(); }
True
False
Complier error
What is output of code? #include #include void main() { if(1,0) printf("True"); else printf("False"); getch(); }
True
False
Complier error
What is output of code? #include #include void main() { int i, j, *ptr, *ptr1; i = 10; j = 10; ptr = &i; ptr1 = &j; if(ptr == ptr1) printf("True"); else printf("False"); getch(); }
True
False
Complier error
What is output of code? #include #include void main() { int i; i = 2; DES: printf("%d", i); i = i + 2; if(i <= 20) goto DES;
=>
2468101214161820
468101214161820
nothing is printed
What is output of code? #include #include void main() { int i; i = 0; if(i = 15, 10, 5) printf("C/C++ %d", i); else printf("Java %d", i); getch(); }
C/C++ 15
Java 15
Java 5
Complier error
What is output of code? #include #include void main() { int a = 80; if(a++ > 80) printf("C/C++ %d", a); else printf("Java %d", a); getch(); }
C/C++ 80
C/C++ 81
Java 80
Java 81
What is output of code? #include #include void main() { int a; a = 1; while(a <= 1) if(a%2) printf("%d ", a++); else printf("%d ", ++a); printf("%d ", a+10); getch(); }
=>
1 12
2 12
2 11
What is output ? #include #include #include #include void myfunc(char** param) { ++param; } void main() { char* string = (char*)malloc(64); strcpy(string, "hello_World"); myfunc(&string); myfunc(&string); printf("%s\n", string); getch(); }
hello_World
ello_World
llo_World
lo_World
What is output? void myfunc(char** param) { ++*param; } void main() { char* string = (char*)malloc(64); strcpy(string, "hello_World"); myfunc(&string); myfunc(&string); printf("%s\n", string); getch(); }
hello_World
ello_World
llo_World
lo_World
What is output? void main() { int ints[] = { 0, 1, 2, 3 }; int* i1 = ints + 1; int a = ++*i1; int b = a + *i1; printf("%d\n", b); getch(); }
3
4
5
6
What is output? void main() { int ints[] = { 0, 5, 10, 15 }; int* i2 = ints + 2; int a = *i2++; // a = *(i2++); printf("%d#%d\n", a, *i2); getch(); }
10#15
10#10
15#15
11#15
