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

what is 12minus 2 multiply 6 plus 2 divide by 2
How did Niccolo Machiavelli’s book The Prince set him apart from other writers of the Renaissance?
Heat is released when H2 gas and O2 gas react to form H2O. Why? A. Breaking the H–H bond in H2 gas releases heat. B. Breaking the O–O bond in O2 gas releases he
What's the word for wandering about; tending to move around, travel
What's the other term for: explosive or changing very quickly
round to the nearest hundredth 5.6192
What's the other word speaking in circles; round-about speech
What is the answer to 12-2x6+2/2
a subway train starts from rest at a station and accelerates uniformly at 1.8m/s^2 for 15 sec. then it runs at a constant speed for the next 35 sec. before dece
What's the word for looking down on others; proud and scornful