In: Computer Science
What is the output of the code below? After each line that has a cout, write what the output of the code is. See example in code below.
int i = 2, j = 1, k = i + j;
cout << k << endl; ➔ 3
double d = 2.99, e = 1, f = d + e;
cout << f << endl; double q = 1.50;
cout << q/3 << endl;
cout << 6.0/4 << endl;
char c = 65; int n = 65;
bool b = true;
if (b == true) cout << "b is true" << endl;
else cout << "b is not true" << endl;
if (c == n) cout << c << n << endl;
int i = 1.25, j = 1, k = i + j;
cout << k << endl;
cout << 1 / 3 << endl;
cout << 1 / 3.0 << endl;
char c = 'A'; c = c + 1;
int n = c; cout << c << n << endl;
Solution:
The output of the given code is provided below:
Explanation:
cout << q/3 << endl;
cout << 6.0/4 << endl;
cout << k << endl;
cout << 1 / 3 << endl;
cout << 1 / 3.0 << endl;
cout << c << n << endl;