Question PRG-CPP-0021
EasyWhat is the output of this program?
#include <iostream>
using namespace std;
int main() {
cout << 5 / 2 << " " << 5.0 / 2;
return 0;
}
- A.
2.5 2.5
- B.
3 2.5
- C.
Show answer and explanation
Answer: D
5 / 2 is integer division (2); 5.0 / 2 is floating-point division (2.5).