+ 1

What is the output of the following cpp program and please explain how that output came?

#include<iostream> using namespace std; int main () { int a=7; int b=3; cout<<a/b+a; }

29th Jun 2017, 9:55 AM
Dhruv Sharma
Dhruv Sharma - avatar
6 Antworten
+ 18
a/b means 7/3. The quotient after the division of 7 by 3 is added to the value of the variable a. 7/3 = 2; (3*2 = 6) the remainder results to 1 but the quotient is 2. and 2+7 = 9; where 7 is the value of a.
29th Jun 2017, 10:03 AM
Dev
Dev - avatar
+ 3
9?
29th Jun 2017, 9:57 AM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
+ 3
#include<iostream> using namespace std; int main () { int a=7; int b=3; cout<<(a/b)+a; // a/b= 7/3=2,33 } //type int without virgul //2,33->2 //2+a = 2+7 =9
29th Jun 2017, 10:19 AM
Elie Douaihy
Elie Douaihy - avatar
+ 3
thank you so much..for detailed explaination exactly what i want thank you...
29th Jun 2017, 10:20 AM
Dhruv Sharma
Dhruv Sharma - avatar
+ 1
it 9
29th Jun 2017, 8:10 PM
Hassan Jaber
Hassan Jaber - avatar
0
yeah its right but i want to know how that 9 came
29th Jun 2017, 9:58 AM
Dhruv Sharma
Dhruv Sharma - avatar