Question: 1)Predict the output of the following program segment loop. int x = 1; for(int m = 1; m < 5; m + +) x +
1)Predict the output of the following program segment loop.
int x = 1;
for(int m = 1; m < 5; m + +)
x + = m;
cout << " x = " << x << endl;
(a) 10 (b) 12 (c) 9 (d) 15 (e) 11
2)Predict the output of the following program segment loop.
int year = 1;
double amount = 25000;
while(year < = 5)
{
amount * = 1.20;
year + +;
}
cout << " salary = " << amount << endl;
(a) 36000 (b) 62208 (c) 51840 (d) 74649.6 (e) 43200
3)Which of these is the second step in the order of events involving a for loop?
(a) Update variable (b) Test expression
(c) Execute body of loop if expression is true (d) Initialize variable
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
