KaiDeguzzy3774 KaiDeguzzy3774
  • 02-07-2020
  • Computers and Technology
contestada

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.

Respuesta :

frknkrtrn
frknkrtrn frknkrtrn
  • 07-07-2020

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;

}

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)

Answer Link

Otras preguntas

10 8 6 4 2 X -10 -8 -6 -4 -2 0 2 4 6 8 10 -2 -4 What is the equation of the line in slope-intercept form? arm N
In 8 divided by 1/5 the number 8 is the?
Why does Great Britain have a mild climate despite being located near the Arctic Circle?
Graham paid $87.45 for a pair of jeans. This amount included a tax of 40%. What was the cost of the jeans before tax?
what requirement was necessary in order to vote for county delegates in the house of commons? what was the result? why?
Why does Great Britain have a mild climate despite being located near the Arctic Circle?
4. Which passage from the excerpt most strongly suggests that Phineas is in danger of having an accident?
Write the fraction as a decimal 4 -8 11 4 , and 8 over 11
In 8 divided by 1/5 the number 8 is the?
HELP WITH THIS QUESTIONS PLSSSSSS. What is the slope of the line 0,-2 and 2, 8