Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write code in C++ Write a program using a do-while loop that increments the valu

ID: 669965 • Letter: W

Question

write code in C++

Write a program using a do-while loop that increments the value of a variable y by 10 each pass through the loop. Initialize variable y to zero.

User will input a number to the variable count from the keyboard. The variable count gives the number of loop repetitions to be made, and is the limit in the while conditional statement, e.g. while(x<=count). User will determine the value of count when entered from the keyboard.

Reference value for the variable x, the cycle counter, should be initialized at zero.

Output the value of y to the screen during the loop.

The program must use the variable names given above, and for the stated purposes.

The objective is to observe and understand the result of the value of y for various numbers of repetitions of the loop.

Explanation / Answer

#include <iostream>

using namespace std;

int main()

{

int x = 1,y = 0,count = 0;

  

cout << "Enter the number of repititions : ";

cin >> count;

  

while(x<=count)

{

y = y+10;

x = x+1;

cout << "Value of y : " << y << endl;

}

return 0;

}