syntax problem

Hi
This is my syntax


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

int main()
{
string name;
int x = 1;

if (x == 2)
cout << "it worked";

else if (x == 1)

cout << "Hi what is your name ";
getline (cin, name);

if (name == "mark");

x + 1;

}

What I want to do is' when the user enters there name as mark I want to add 1 to x and so it runs the if (x == 2) part of the code.
Could some one please tell me what I did wrong the code compiles fine but dose not print the if (x == 2).

Thanks to any one who can help me.
statement
Your code adds one to x at the end (well, actually it doesn't - I suspect you meant x = x+1;, but you actually wrote x+1;, which does nothing). At the end. Then the program finishes. How do you expect it to suddenly go back to the start?

You need to learn about loops. http://www.cplusplus.com/doc/tutorial/control/


Last edited on
Yes thats exactly what I need Thank You Moschops
Topic archived. No new replies allowed.