0

What is answer of this

a=13 b=7 a/=b cout<<b-a

11th Sep 2016, 5:14 AM
Nandan jindal
Nandan jindal - avatar
6 Réponses
+ 1
It depends on the a and b variables' data types. For double and float it is 5.14286. For int is is 6. http://code.sololearn.com/c0jpgaSEC1K8/ // Double (and float) keep decimal fractions double doubleA = 13; double doubleB = 7; doubleA /= doubleB; // A/B = 13/7 = 1.85714. A = 1.85714 cout << "Double: " << doubleB - doubleA << endl; // B-A = 7-1.85714 = 5.14286 // Int truncates decimal fractions int intA = 13; int intB = 7; intA /= intB; // A/B = 13/7 = 1.85714, but is truncated down to 1, so now A = 1 cout << "Int: " << intB - intA << endl; // B-A = 7-1 = 6
11th Sep 2016, 3:52 PM
Liam
Liam - avatar
0
6
11th Sep 2016, 7:05 AM
Programmer
0
a=a/b; //13/7=1.system don't take in. float.so,now a=1 b-a=7-1=6
13th Sep 2016, 9:13 AM
susmitha gummadi
susmitha gummadi - avatar
0
a=a/b; //13/7=1.system don't take in. float.so,now a=1 b-a=7-1=6
13th Sep 2016, 9:14 AM
susmitha gummadi
susmitha gummadi - avatar
- 1
6
11th Sep 2016, 9:42 AM
suresh
- 1
if in float it is =7-1.7=6.3 and if it is int then =7-1=6
12th Sep 2016, 6:17 AM
Mohd Shahrukh
Mohd Shahrukh - avatar