Display Your Name

Program to display your name on the screen

BeginnerTopic: Basic Programs
Back

C++ Display Your Name Program

This program helps you to learn the fundamental structure and syntax of C++ programming.

Try This Code
#include <iostream>
#include <string>
using namespace std;

int main() {
    string name = "John Doe";
    cout << "My name is: " << name << endl;
    return 0;
}
Output
My name is: John Doe

Understanding Display Your Name

This program demonstrates how to use string variables and display them. We declare a string variable 'name' and assign it a value. The cout statement concatenates the text with the variable value using the << operator.

Note: To write and run C++ programs, you need to set up the local environment on your computer. Refer to the complete article Setting up C++ Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your C++ programs.

Table of Contents