LearnFrenzy
Sign in Take a free test

Operators and Expressions · Exercise 2 of 4

Operators and Expressions Predict the Output

  • 12 questions
  • Page 2 of 2
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Read each program and choose what it prints. Every program was compiled and run, so the answers are the real output.

Question 11 Easy

What is the output of the following C program?

main.c
#include <stdio.h>

int main(void) {
    int n = 10;
    n /= 4;
    n *= 4;
    printf("%d\n", n);
    return 0;
}
A 8
B 10
C 12
D 2
Question page & discussion
Question 12 Hard

What is the output of the following program, compiled as C23?

main.c
#include <stdio.h>

int main(void) {
    auto r = 3 > 2;
    bool b = 3 > 2;
    printf("%zu %zu %d\n", sizeof r, sizeof b, r + b);
    return 0;
}
A 4 1 2
B 1 1 2
C 4 4 2
D 1 1 1
Question page & discussion
Up next · Exercise 3Find the Error8 questions

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links