Create an application named NumbersDemo whose main() method holds two integer variables. Assign values to the variables. In turn, pass each value to methods named displayTwiceTheNumber(), displayNumberPlusFive(), and displayNumberSquared().

Respuesta :

Answer:

The solution code is written in C++.

  1. int main() {
  2.    int a = 5;
  3.    int b = 4;
  4.    displayTwiceTheNumber(a);
  5.    displayTwiceTheNumber(b);
  6.    displayNumberPlusFive(a);
  7.    displayNumberPlusFive(b);
  8.    displayNumberSquared(a);
  9.    displayNumberSquared(b);
  10.    return 0;
  11. }
  12. void displayTwiceTheNumber(int num){
  13.    cout << num * 2;
  14. }
  15. void displayNumberPlusFive(int num){
  16.    cout << num + 5;
  17. }
  18. void displayNumberSquared(int num){
  19.    cout << num * num;
  20. }

Explanation:

Firstly, create two integer variables, a and b and two sample values are assigned to the two variables, respectively (Line 3-4). Next, we pass the value of each variable a and b to the methods named displayTwiceTheNumber(), displayNumberPlusFive(), and displayNumberSquared() (Line 6- 13).

ACCESS MORE