VERY SIMPLE!! Won't run correctly

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

//Create a simple C++ program to:
// 1. Ask the user for name
// 2. Ask for age
// 3. Greet the user by name
// 4. Say if the user can vote
// 5. Repeat # 1 and # 2

int main ()
int userName;
int userAge;

cout<< "Hello! What's your name?"<<endl;

cout<<"And how old are you?"<<endl;

cout<<"Well hello "<<userName<<" you're "<<userAge<<" right?"<<endl;

if (userAge < 18)
cout<<"I'm sorry - you're not able to vote yet"<<endl;

cout<<"Congrats! You can vote!"<<endl;

system ("pause");
return 0;
You need to use a string for the username, not an integer. Also, take a look at getline for taking input into the string -

Also, system("pause") is not required and is platform specific.

You also do not call anything from iomanip, so no need to include that extra header file. ;)
Topic archived. No new replies allowed.