Question 31
MediumWhat is the output of this program?
#include <stdio.h>
int {
s[] = ;
(, (s));
;
}
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 {
s[] = ;
(, (s));
;
}
5
8
6
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(void) {
int a[] = {10, 20, 30, 40};
int *p = a;
printf("%d", *(p + 2));
return 0;
}
Error
20
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(void) {
int a = 0, b = 0;
int r = a && (b = 1);
r = a || (b = 1);
printf("%d %d", a, b);
return 0;
}
1 1
0 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() {
int a[] = {10, 20, 30, 40};
int *p = a + 1;
printf("%d %d %d", *p, *(p + 2), p[-1]);
return 0;
}
20 40 10
20 30 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 x = 5;
int *p = &x;
int **q = &p;
**q = 12;
printf("%d", x);
return 0;
}
12
5
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";
printf("%zu %zu", sizeof(s), sizeof("hi"));
return 0;
}
6 2
5 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() {
int i, s = 0;
for (i = 0; i < 10; i++) {
if (i % 3 == 0) continue;
if (i == 8) break;
s += i;
}
printf("%d %d", s, i);
return 0;
}
21 8
27 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 x = 7;
switch (x % 4) {
case 1: printf("one ");
case 3: printf("three ");
case 2: printf("two ");
break;
default: printf("other ");
}
return 0;
}
three two
other
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 int u = 0;
u = u - 1;
printf("%d", u > 100);
return 0;
}
Compilation error
-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() {
int a = 10, b = 3;
printf("%d %d %d %.2f", a / b, a % b, -a / b, (float)a / b);
return 0;
}
3 1 -3 3.00
3 1 -3 3.33
Sign up free to see the answer and a step-by-step explanation.
30
10
0 0
1 0
10 30 20
21 22 9
Address of x
Compilation error
8 8
6 3
19 8
19 10
three
one three two
1
0
3 1 -4 3.33
3.33 1 -3 3.33