Question 61
HardWhat is the output of this program?
#include <stdio.h>
int {
( < )
();
();
;
}
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Programming Languages
What is the output of this program?
#include <stdio.h>
int {
( < )
();
();
;
}
a
b
Error
c
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <stdio.h>
int main() {
int a[] = {1, 2, 3, 4, 5};
int *p = a, *q = &a[4];
printf("%td %d %d", q - p, *(p + 3), *q - *p);
return 0;
}
16 4 4
5 4 4
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <stdio.h>
int main() {
int a[2][3] = {{1, 2, 3}, {4, 5, 6}};
int (*p)[3] = a;
printf("%d %d %d", *(*(p + 1) + 2), **p, *(p[0] + 1));
return 0;
}
6 4 2
3 1 2
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <stdio.h>
int main() {
char s[] = "hello";
char *t = "hello";
printf("%zu %zu %d", sizeof(s), sizeof(t) == sizeof(char *), s[5] == '\0');
return 0;
}
6 0 1
6 1 1
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <stdio.h>
int main() {
unsigned char c = 250;
c += 10;
signed char d = 127;
d++;
printf("%d %d", c, d);
return 0;
}
4 128
260 -128
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <stdio.h>
int main() {
int x = 10;
int y = x++ + 5;
int z = ++x * 2;
printf("%d %d %d", x, y, z);
return 0;
}
12 15 24
11 15 22
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <stdio.h>
int main() {
int i = 0, s = 0;
while (i < 10) {
i++;
if (i % 2) continue;
if (i > 7) break;
s += i;
}
printf("%d %d", s, i);
return 0;
}
6 8
20 10
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <stdio.h>
int main() {
int a = 5, b = 0;
if (b != 0 && a / b > 1) printf("big ");
else printf("safe ");
printf("%d", (a > 3) + (a > 4) + (a > 5));
return 0;
}
safe 3
Runtime error
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <stdio.h>
int main() {
int x = 0x1F;
printf("%d %o %X %d", x, x, x << 2, x >> 3);
return 0;
}
31 37 7C 4
31 31 7C 3
Sign up free to see the answer and a step-by-step explanation.
What is the output of this program?
#include <stdio.h>
int f(int n) { return n <= 1 ? 1 : n * f(n - 1); }
int g(int n) { return n == 0 ? 0 : n % 10 + g(n / 10); }
int main() {
printf("%d %d", f(5), g(9045));
return 0;
}
60 18
24 18
Sign up free to see the answer and a step-by-step explanation.
4 4 4
4 3 4
6 1 2
5 1 2
5 1 1
8 1 0
4 -128
260 128
12 15 22
12 16 24
12 8
12 10
safe 2
big 2
31 37 7C 3
1F 37 7C 3
120 9
120 18