Use function GetUserInfo to get a user's information. If user enters 20 and Holly, sample program output is:Holly is 20 years old.#include <iostream>#include <string>using namespace std;void GetUserInfo(int& userAge, string& userName) {cout << "Enter your age: " << endl;cin >> userAge;cout << "Enter your name: " << endl;cin >> userName;}int main() {int userAge;string userName;/* Your solution goes here */cout << userName << " is " << userAge << " years old." << endl;return 0;}Please help me with this problem using c++.

Question
Asked Nov 9, 2019
78 views

Use function GetUserInfo to get a user's information. If user enters 20 and Holly, sample program output is:

Holly is 20 years old.

#include <iostream>
#include <string>
using namespace std;

void GetUserInfo(int& userAge, string& userName) {
cout << "Enter your age: " << endl;
cin >> userAge;
cout << "Enter your name: " << endl;
cin >> userName;
}

int main() {
int userAge;
string userName;

/* Your solution goes here */

cout << userName << " is " << userAge << " years old." << endl;

return 0;
}

Please help me with this problem using c++.

check_circle

Expert Answer

Step 1

Completing the given C++ program so, that it can follow the given rubrics:

  • In the main function, calling the GetUserInfo() function.
  • This function displays a message to the user to enter the age.
  • Taking input of number of age from the user.
  • Again, displaying a message to the user to enter the name.
  • Taking input of name from user.
  • Displaying the output to user in the given format.

For ex, if the user entered age is 20 and user entered name is holly, then the output can be Holly is 20 years old.

Step 2

Program code:

 

//importing neccessary header files

#include <iostream>

#include <string>

using namespace std;

//function defination

void GetUserInfo(int& userAge, string& userName) {

//displaying message to use to enter the age 

cout << "Enter your age: " << endl;

//taking input of age

cin >> userAge;

//displaying message to user to enter the name 

cout << "Enter your name: " << endl;

//taking input of user name

cin >> userName;

}

//main method

int ma...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: This is the question: Suppose that we want to synthesize a circuit that has two switches x and y. Th...

A: Here in this synthesize circuit NOT AND and OR gate is used. So let us try to understand the figure ...

question_answer

Q: C++    Write a recursive program that finds out if n is a Fibonacci number or not. The Fibonacci num...

A: The C++ program will follow the given rubrics:Importing header files.Displaying the message to user ...

question_answer

Q: Create a class of type student .Members will include: name, gpa, rank (year) Make sure all data is p...

A: The name of the class is Student.All data is a private member of the class.All function is a public ...

question_answer

Q: I need help programming this problem in C++   Given an array of N elements, what is the average numb...

A: Linear Search:Take the array of N number of elements. Best case:Assume, that the search element is a...

question_answer

Q: What 1s the output of the following code! { String myStr = new String("Cheggers2019") ; System.out.p...

A: There seems to be some error in the question, hence we are proceeding with a small assumption on our...

question_answer

Q: Create a new file (in Dev C++)  In Lab 2, you created a menu for a simple calculator program. In Lab...

A: Program AlgorithmDeclare the required variables and write a welcome message before starting the menu...

question_answer

Q: Python 3.7.4 The current calendar, called the Gregorian calendar, was introduced in 1582. Every year...

A: The following is the source code which takes the input from the user and tells whether the input yea...

question_answer

Q: Assignment First, launch NetBeans and close any previous projects that may be open (at the top menu ...

A: A Java program that prompts the user for five to ten numbers, and calculates the average of those nu...

question_answer

Q: Create a new file (in Dev C++) and save it as lab11_XYZ.cpp (replace XYZ with your initials). Create...

A: Program:Filename: lab11_XYZ.cpp// header files #include &lt;iostream&gt; #include "swap_XYZ.h" using...