C++ Strings, C++ String Programming, String Programming Examples
Write a C++ program to display a string entered by user during run-time.

Note: We you enter any value for name then it can not consider space as character. i.e if you enter value of string as Mukesh Rajput, then only Mukesh is considered as string value. 


#include <iostream>
using namespace std;
int main()
{
    char name[25];
    cout<< "Enter a string to display : ";
    cin>>name;
    cout<<"You entered a string to display is : " ;
    cout<< name;
    cout<< endl;
    cout<< "Enter another string to display is : ";
    cin>> name;
    cout<< "You entered another string to display is : " ;           
    cout<<name;
    cout<<endl;
    return 0;
}


Program output is tested on www.jdoodle.com

Output:
Enter a string to display : Mukesh Rajput
Enter another string to display is : Suruchika Thakur
You entered a string to display is : Mukesh 

You entered another string to display is : Suruchika


Thanks
Mukesh Rajput


Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: