Titus Jr I.

asked • 11/15/20

Declaring and Initializing C++ Constants

In this lab, you declare and initialize constants in a C++ program. The program, which is saved in a file named NewAge2.cpp, calculates your age in the year 2050.

Instructions

  1. Declare a constant named YEAR, and initialize YEAR with the value 2050.
  2. Edit the statement myNewAge = myCurrentAge + (2050 − currentYear) so it uses the constant named YEAR.
  3. Edit the statement cout << "I will be " << myNewAge << " in 2050." << endl; so it uses the constant named YEAR.
  4. Execute the program by clicking the Run button at the bottom of the screen.


1 Expert Answer

By:

Patrick B. answered • 11/15/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.