954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

really need this badly

im a highschool student and i really need help bout this....

how can i make a program that will enter my name and display it automatically.....

jonabie
Newbie Poster
5 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 
#include <iostream>
#include <string>
using namespace std;

int main(){
  string yourName;
  cout<<"Enter your name: ";
  cin>>yourName;
  cout<<"Your name is: "<<yourName<<endl;
  return 0;
}
Narf!!!
Newbie Poster
11 posts since Aug 2008
Reputation Points: 10
Solved Threads: 1
 
#include <iostream>
#include <string>
using namespace std;

int main(){
  string yourName;
  cout<<"Enter your name: ";
  cin>>yourName;
  cout<<"Your name is: "<<yourName<<endl;
  return 0;
}

or without using #include <iostream>
using namespace std;

int main(){
char yourName[100]; /*you must declare how much input you're going to read */
cout<<"Enter your name: ";
cin>>yourName;
cout<<"Your name is: "<<yourName<<endl;
return 0;
}


Kind Regards

Narf!!!
Newbie Poster
11 posts since Aug 2008
Reputation Points: 10
Solved Threads: 1
 

hey guys_!!!!
tnx for the support!!!!
Luvyah all!!!

jonabie
Newbie Poster
5 posts since Aug 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You