79.9k views
2 votes
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 Answer

0 votes

Answer:

#include <iostream>

using namespace std;

int main()

{

const int YEAR = 2050;

int currentYear = 2020;

int currentAge = 38;

cout<<"You will be " << currentAge + (YEAR - currentYear) << " years old in " << YEAR;

return 0;

}

Step-by-step explanation:

Initialize the YEAR as a constant and set it to 2050

Initialize the currentYear as 2020, and currentAge as 38

Calculate and print the age in 2050 (Subtract the currentYear from the YEAR and add it to the currentAge)

User Vintrojan
by
5.7k points