POROGRAMMING C Requirements Design and write a program which

POROGRAMMING C++

Requirements
Design and write a program which covers a minimum of ANY SIX (6) of
the following items.
1) Variable(s)
2) Escape sequence(s)
3) Assignment statement(s)
4) Initialization statement(s)
5) Comment statement(s)
6) cin function(s) to read user input
7) Expression(s)
8) Any function(s) from the iomanip library.
9) Any function(s) from the cmath library.
10) Constant variable(s)

Solution

// C++ code

#include <iostream> // std::cout, std::fixed
#include <iomanip> // std::setprecision
#include <math.h>

using namespace std;

// 10) Constant variable(s)
const int n = 3;
const int m = 5;

// This is the main function (where the program begins)
int main()
{

// 1) Variable(s)
int sum, product, power;
int number1;

// 4) Initialization statement(s)
int number2 = 5;

// 3) Assignment statement(s)
sum = 0;


// 4) Initialization statement(s)
cout << \"Program to add, multiply numbers and power \ \";

// 5) Comment statement(s)
// comment: taking input from user
// 6) cin function(s) to read user input
cout << \"Enter number1: \";
cin >> number1;

  
// 7) Expression(s)
sum = number1 + number2 + n;
product = number1 * number2 * n;

// 9) function from the cmath library. : power function
power = pow(number1,number2);

// 2) Escape sequence(s) => \"\\t\", \"\ \"
// 8) function from the iomanip library : setprecision
cout << number1 << \"+\" << number2 << \"+\" << n << \" : \" <<std::setprecision(2) << sum << \'\ \';
cout << number1 << \"*\" << number2 << \"*\" << n << \" : \" <<std::setprecision(2) << product << \'\ \';
cout << number1 << \"^\" << number2 << \" : \" <<std::setprecision(2) << power << \'\ \';

return 0;
}


/*
output:

Enter number1: 3

3+5+3 : 11
3*5*3 : 45
3^5 : 243

*/

POROGRAMMING C++ Requirements Design and write a program which covers a minimum of ANY SIX (6) of the following items. 1) Variable(s) 2) Escape sequence(s) 3) A
POROGRAMMING C++ Requirements Design and write a program which covers a minimum of ANY SIX (6) of the following items. 1) Variable(s) 2) Escape sequence(s) 3) A

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site