Question discussion

What is the output of the following C++ program?#include using namespace std; int main() { cout

1979Medium DSSSB TGT Computer Science 0 replies 1 views
0

What is the output of the following C++ program?

#include <iostream>
using namespace std;
int main() {
    cout << 7 / 2 << " " << 7 % 2 << " " << 7 / 2.0;
    return 0;
}
  • A3 1 3.5
  • B3.5 1 3.5
  • C3 1 3
  • D3 0 3.5
Correct answer: A

Explanation

7 / 2 is integer division (3), 7 % 2 is 1 and 7 / 2.0 is floating-point division (3.5).

Discussion 0

Nobody has replied yet. Start the discussion!