What are the values of the variables a b c d and e after the
Solution
c++ program for the same question.
#include <iostream>
using namespace std;
int main() {
int a = 5;
int b = 20;
double c = 35.0;
int d = 15;
double e = 10.0;
a++;
//This is increment operation.
// It executes just like a=a+1; so, the value of a is incremented by 1.
//Hence value of a becomes 6. (see executed output below)
b = b*a;
// This line simply multiplies the value of a by b and then stores it in b. By this time the value of a is 6.
// Hence b = 20 * 6. The val;ue of b would now be 120. (see executed output below)
c-=e;
//This works like. c = c-e . hence c will now store 35.0-10.0 .
//The value in c is 25. (see executed output below)
d=(7+b)%10;
// First here, 7+120 happens which is 127. then modulus of 127 by 10 will happen.
// the result of this is 7. Hence d stores 7 now. (see executed output below)
e=(a/50) * (c*c);
// first 6/50 happens. 6 is not divisible by 50 . hence the value will become zero here itself.
// further multiplication also results in zero.
// e will now store 0. (see executed output below)
cout<<\"Value of a: \"<<a<<endl;
cout<<\"Value of b: \"<<b<<endl;
cout<<\"Value of c: \"<<c<<endl;
cout<<\"Value of d: \"<<d<<endl;
cout<<\"Value of e: \"<<e<<endl;
return 0;
}
OUTPUT:
Value of a: 6
Value of b: 120
Value of c: 25
Value of d: 7
Value of e: 0
