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
Post A Comment:
0 comments: