Challenge: Profile Card

Lab C++ Beginner 10 points

Create these variables: a string name Riya, an int age 21 and a double height 1.65. Then print them like this:

Name: Riya
Age: 21
Height: 1.65

Input

None.

Output

The three lines above.

Example

Output

Name: Riya
Age: 21
Height: 1.65
Sample output available
Editor
C++

Hints

#include <string> to use string.

Print the label in quotes, then the variable without quotes.

Solution explanation

Each variable has a type that fits its value: text, a whole number and a decimal.

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

int main() {
    string name = "Riya";
    int age = 21;
    double height = 1.65;
    cout << "Name: " << name << "\n";
    cout << "Age: " << age << "\n";
    cout << "Height: " << height << "\n";
    return 0;
}
Output
Answer
HOME LABS COMMUNITY DASHBOARD