1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
yarga [219]
3 years ago
5

Summary In this lab, you declare and initialize variables in a C++ program. The program, which is saved in a file named NewAge.c

pp, calculates your age in the year 2050. Instructions Declare an integer variable named myNewAge. Declare and initialize an integer variable named myCurrentAge. Initialize this variable with your current age. Declare and initialize an integer variable named currentYear. Initialize this variable with the value of the current year. Use four digits for the year. Execute the program by clicking the Run button at the bottom of the screen. Sample program execution: My Current Age is 29. I will be 65 in 2050.
I am not sure how to add my output.

This is what I have so far:

// This program calculates your age in the year 2050.

// Input: None // Output: Your current age followed by your age in 2050

#include using namespace std;

int main()

'currentYear'; /2019/.match('currentYear') =>MatchData "2019"

'myCurrentAge'; /20/.match('myCurrentAge') => > "My Current Age is" count >> 'myCurrentAge'

int 'currentYear'

'currentYear'= 2019;

count >> "Current Year"

count >> 'currentYear'

int 'myNewAge'

'myNewAge'= 51;

count >> "I will be"

count >> 'myNewAge'

51 = 20 + (2050 - 2019);

cout << "My Current Age is " << 20 << endl;

cout << "I will be " << 51 << " in 2050." << endl;

return 0; }
Computers and Technology
1 answer:
AVprozaik [17]3 years ago
7 0

Answer:

<em>#include <iostream></em>

<em>using namespace std;</em>

<em>int main()</em>

<em>{</em>

<em>  int myNewAge;</em>

<em>  int myCurrentAge = 29;</em>

<em>  int currentYear = 2020;</em>

<em> </em>

<em>myNewAge = myCurrentAge+(2050-currentYear);</em>

<em />

<em>cout<<"My Current Age is "<<myCurrentAge<<". I will be "<<myNewAge<<" in 2050"<<endl;</em>

<em>    return 0;</em>

<em>}</em>

Explanation:

The program is written in C++ language as required. firstly, we declare the three variables:

<em>  </em><em>int myNewAge;</em>

<em>  int myCurrentAge = 29;</em>

<em>  int currentYear = 2020;</em>

Then we calculate the new age as: <em>myNewAge = myCurrentAge+(2050-currentYear);</em>

Using multiple cout operators (<em> </em><<) we display the output nicely as required by the question with this statement

<em>cout<<"My Current Age is "<<myCurrentAge<<". I will be "<<myNewAge<<" in 2050"<<endl;</em>

You might be interested in
Atomic Term If an atom carries no charge, the positive charges from protons are balanced by the negative charges from the
Neko [114]

Answer:

yee ha

Explanation:

7 0
3 years ago
The master production schedule for Product A shows a need for 30 units, and Product B shows a need of 25 units. To manufacture a
alexandr1967 [171]

Answer:

the amount of C required is 190 units of C

Explanation:

the amount of C to cover the necessity of product A is

Ca = A units required * number of C units to manufacture a unit of A

Ca = 30 unit of A * 3 units of C/ unit of A =90 units of C

to produce B the same applies

Cb = B units required * number of C units to manufacture a unit of B

Cb = 25 unit of B * 4 units of C/ unit of B =100 units of C

therefore to cover the necessities of A and also B we will need:

total units of C required = units of C to produce A + units of C to produce B

C = Ca + Cb = 90 units of C + 100 units of C = 190 units of C

C= 190 units of C

3 0
3 years ago
The space where text and content is entered and positioned for onscreen reading or printing
tino4ka555 [31]

Answer:

Page.

Explanation:

A page typically occupies the largest portion of a document layout as it houses the main writeup or content of the document. The text contained in a document is written on a the main page of the document. The main page is surrounded by the page margin, which is an area which separates the tips or edges of an entire papwr and the writing area (page) of the document. The insertion point refers to an indicator which shows the position which a typed character will fall or be placed. Content written on a document's page is what is printed when the document is to be printed out and test entered on the page are what is seen by the reader.

4 0
3 years ago
I need help pls, in this code if add row for example :
tankabanditka [31]
I thing is going project experiment everyone make plans and
3 0
4 years ago
#include #include int main( ) { int value = 10; int pid; value += 5; pid = fork( ); if (pid &gt; 0 ) { value += 20; } printf(val
ss7ja [257]

Explanation:

To understand how this program is working let us print the variable value at different stages of the program so that we can understand how it is working.

Intitally, value=10 when it was declared.

Then we added 5 and it become value=15

then we used fork() function which creates a parent(orignal) and child(duplicate)

When fork() succeeds it returns the child pid to parent and returns 0 to the child. As you can see (pid > 0) condition is always true therefore the parent pid value becomes 35 ( 15+20) and the child pid value becomes 0.

#include <stdio.h>

#include <unistd.h>

int main( ) {

   int value = 10;

     printf("%d\n",value);

   int pid;

   value += 5;

     printf("%d\n",value);

   pid = fork( );

     printf("%d\n",pid);

   if (pid > 0 )

   {

       value += 20;

   }

   printf("%d\n",value);

   return 0;

}

Output:

10 (initial value)

15 (modified value)

5343 (pid when fork is used)

35 (final modified value)

0 (child value)

15 (the parent value when fork was used)

8 0
4 years ago
Other questions:
  • Which of the following is the correct syntax for a hyperlink:
    7·1 answer
  • Which term is used to describe bitmap images
    8·2 answers
  • Jennifer, a customer, informs you that unexpected icons are appearing on her system's desktop. You identify the symptoms of the
    12·1 answer
  • Over a TCP connection, suppose host A sends two segments to host B, host B sends an acknowledgement for each segment, the first
    6·1 answer
  • Sensitive data is always classified true or false
    14·1 answer
  • When connecting past and present issues, it is best to follow a series of steps. Which step is missing from the pattern? 1. Iden
    13·1 answer
  • Please Help meeeeeeeeeee:
    11·2 answers
  • Which item best describes fiber optic transmission?
    14·1 answer
  • 1. Give one reason why data is represented in binary in a computer [1]
    10·1 answer
  • 1.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!