Thursday, 5 January 2017

Write a program that generates the following output: 10 20 19 Use an integer constant for the 10, an arithmetic assignment operator to generate the 20, and a decrements operator to generate the 19.

Leave a Comment


Question:

Write a program that generates the following output:
            10
            20
            19
Use an integer constant for the 10, an arithmetic assignment operator to generate the 20, and a decrements operator to generate the 19.

Explanation:
Below mention code is compiled in Visual Studio 2015 and Code Blocks 13.12,output snap is attached.. If any problem you feel and you want some explanation feel free to contact us.

Code:

/**************************************************|
/*************C++ Programs And Projects************|
***************************************************/
#include <iostream>
using namespace std;
int main()
{
       int var = 10;
       cout << var << endl;      // var is 10
       var *= 2;                 // var becomes 20
       cout << var-- << endl;    // displays var, then decrements it
       cout << var << endl;      // var is 19
       return 0;

}

Output:

Write a program that generates the following output:             10             20             19 Use an integer constant for the 10, an arithmetic assignment operator to generate the 20, and a decrements operator to generate the 19.


Related Articles:

Object-Oriented Programming in C++ Fourth Edition By Robert Lafore Solution Manual

C++ Books Solution

If You Enjoyed This, Take 5 Seconds To Share It