asked 194k views
0 votes
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().

asked
User Regof
by
8.9k points

1 Answer

3 votes

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. }

Step-by-step 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).

answered
User Tomas Hromnik
by
8.8k points