Question: 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 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.
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
4. Execute the program by clicking the Run button at the bottom of the screen.
DRAFT:
// This program calculates your age in the year 2050.
// Input: None
// Output: Your current age followed by your age in 2050
#include
using namespace std;
int main()
{
int myCurrentAge = 29;
int myNewAge;
int currentYear = 2014;
myNewAge = myCurrentAge + (2050 - currentYear);
cout
cout
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
