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

in c++ that is a do while lets user to input two integers, print and calculate t

ID: 3691007 • Letter: I

Question

in c++ that is a do while lets user to input two integers,

print and calculate the sum of the integers,

then prompt if the user wants to perform the process again.

Variables needed.

decision (holds the user response on if they wish to add more valuse.

num1 ( holds integer value of first number

num2 (holds integer value of 2nd number

total (used to store the sum of both.)

i have this so far please help

#include <iostream>
#include <string>
using namespace std;

int main() {

   int a = 0;
   do
   {
       cout << a << endl;
       a++;

       while (a <= 5);

           system("pause");
       return 0;
   }
}

Explanation / Answer

#include <iostream>
#include <string>
using namespace std;
int main() {
   char c;
  
int num1, num2, total;
do
{
       cout<<"Enter num1: ";
       cin>>num1;
       cout<<"Enter num2: ";
       cin>>num2;
      
       total = num1 + num2;
      
       cout<<"Sum: "<<total<<endl;
      
       cout<<"Do you wan to add more value: press y, else any other...";
       cin>>c;
  
}while(c == 'y');
  
return 0;
}

/*

Sample run:

Enter num1: 3
Enter num2: 4
Sum: 7
Do you wan to add more value: press y, else any other...y
Enter num1: 4
Enter num2: 5
Sum: 9
Do you wan to add more value: press y, else any other...y
Enter num1: 45
Enter num2: 12
Sum: 57
Do you wan to add more value: press y, else any other...n

*/