CJCoding With Joseph
15free / daySign inCreate account
Back to Code Walkthrough

Integer vs Double Division

C++ code walkthrough · Question 40
mediumCasting

Code

Read carefully. What does this print?
1#include <iostream>
2using namespace std;
3int main() {
4 int a = 7, b = 2;
5 double r1 = a / b;
6 double r2 = (double)a / b;
7 cout << r1 << " " << r2 << endl;
8 return 0;
9}

Your answer