In this lab you declare and initialize variables in a c


Declaring and Initializing C++ Variables

Summary

In this lab, you declare and initialize variables in a C++ program. The program, which is saved in a file named NewAge.cpp, calculates your age in the year 2050.

Instructions

  1. Declare an integer variable named myNewAge.
  2. Declare and initialize an integer variable named myCurrentAge. Initialize this variable with your current age.
  3. Declare and initialize an integer variable named currentYear. Initialize this variable with the value of the current year. Use four digits for the year.
  4. Execute the program by clicking the "Run Code" button at the bottom of the screen.

Sample program execution:

My Current Age is 29.

I will be 65 in 2050.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: In this lab you declare and initialize variables in a c
Reference No:- TGS02716531

Now Priced at $10 (50% Discount)

Recommended (99%)

Rated (4.3/5)