Question discussion

What is the output of the following C program?#include int main() { int a = 7, b = 2; printf("%d %d %.1f", a / b, a % b, (float)a / b); ret…

1338Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the output of the following C program?

#include <stdio.h>
int main() {
    int a = 7, b = 2;
    printf("%d %d %.1f", a / b, a % b, (float)a / b);
    return 0;
}
  • A3 1 4.0
  • B3.5 1 3
  • C3 1 3.0
  • D3 1 3.5
Correct answer: D

Explanation

Integer division gives 3, the remainder is 1, and the float division 7/2 prints as 3.5.

Discussion 0

Nobody has replied yet. Start the discussion!