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

how does the ear work (the three different segments in the ear)
Dave buys a baseball for $15 plus an 8% tax. Mel buys a football for $20 plus an 8$ tax. How much did each person pay?
Joanna attended her high school reunion. She was surprised at how easily she and her old friends bonded. She could not help but think that the more things chang
Why do you need a reference point to know if an object is moving
The amendments that were violated in Miranda vs Arizona case
The British chieftan, Calgacus, _____. Select the best answer from the choices provided. spoke glowingly about the benefits of the Pax Romana led one of the
What did the U.S. Peace treaty with spain say?
How does the involvement of victim in the restorative justice process help the victim
why would someone want a midwife to deliver their baby?
The Crimean War ended in the defeat of who?