Ask Question
7 April, 20:35

Given that two int variables, total and amount, have been declared, write a sequence of statements that: initializes total to 0 reads three values into amount, one at a time. After each value is read in to amount, it is added to the value in total (that is, total is incremented by the value in amount). Instructor Notes: Do not use any looping. Just use three cin statements and three calculations.

+1
Answers (1)
  1. 7 April, 21:54
    0
    Following are the program in C+ + language:

    #include / / header file

    using namespace std; / / using namespace

    int main () / / main method

    {

    int amount, total=0; / / two int variable declaration

    cout<<" enter amount:";

    cin>>amount; / / read input amount first time

    total=total+amount; / / first calculation

    cout<<" enter amount:";

    cin>>amount; / /read input amount second time

    total=total+amount; / / second calculation

    cout<<" enter amount:";

    cin>>amount; / / read input amount third time

    total=total+amount; / / third calculation

    cout<<"total:"<
    return 0;

    }

    Output:

    enter amount:12

    enter amount:12

    enter amount:12

    total:36

    Explanation:

    Following are the explanation of program which is mention above

    Declared the two variable total and amount of int type. Initialize the variable total to "0". Read the 3 input in "amount" variable in one by one by using cin function and adding their value to the "total "variable. Finally display the total.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Given that two int variables, total and amount, have been declared, write a sequence of statements that: initializes total to 0 reads three ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers