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>
Answer:
Following are the program to this question:
#include <iostream> //defining header file
using namespace std;
int hailstoneLength(int n) //defining method hailstoneLength
{
int t=1; //defining integer variable assign
while(n!=1) //define a loop that checks value is not equal to 1
{
if(n%2==0) // check even number condition
{
n=n/2; // divide the value by 2 and store its remainder value in n
t++; //increment value of t by 1.
}
else
{
n=n*3+1; //calculate and hold value in n
t++; //increment value of t variable by 1
}
}
return t; //return value
}
int main() //defining main method
{
int n; //defining integer variable
cout<<"Enter any number: "; //print message
cin>> n; //input value
cout<<hailstoneLength(n); //call method and print its value
return 0;
}
Output:
Enter any number: 3
8
Explanation:
Program description can be given as follows:
- In the given C++ language program an integer method "hailstoneLength", is declared, that accepts an integer variable "n" in its parameter.
- Inside the method, an integer variable t is declared, that assign a value that is 1, in the next line, a while loop is declared, that uses if block to check even condition if number is even it divide by 2 and increment t variable value by 1.
- If the number is odd it will multiply the value by 3 and add 1 and increment t by 1 then it will go to if block to check value again. when value of n is not equal to 1 it will return t variable value.
- In the main method, an integer variable "n" is used that call the method and print its return value.
Answer:
What is the purpose of the wordart text effect called Transform?
What is the purpose of the WordArt text effect called Transform? It adjusts the shape of the text. Why is it helpful to combine documents when there are multiple reviewers? This allows users to view color-coded changes from several reviewers in one document.
Explanation:
Answer:
[inaudible]
Explanation:
TranscribeMe is an online transcription company. It employs people all over the world to render transcription services to clients. They have a style guideline which must be strictly adhered to by the transcribers. The guidelines specifically states the "do's " and "dont's" during transcription. Now, when transcribing a word or phrase that cannot be heard or understood due to poor audio or difficult answer, the transcriber uses the tag [inaudible].