Print your name in C++

Share on facebook
Share on twitter
Share on linkedin
Share on twitter
Share on tumblr

In this basic C++ program, we will have a look at how to print your name in C++. This C++ program will print the user’s name with flows. The program requires the user to enter his/her name using input channels, the name is saved and printed with Output Stream in a string variable.

Here is a C++ source code that shows the user’s name with streams.

C++ Program to Print the Name of the User

#include <iostream>
using namespace std;
#define MAX_LENGTH 20
int main()
char name[MAX_LENGTH]={0};
cout<<"Plese enter your name: ";
cout<<"Name: "<<name<<endl;
return 0;


Please enter your name: Robin
Name: Robin

Leave a Comment

Your email address will not be published. Required fields are marked *