whats wrong?


#include <iostream>
#include <conio.h>
#include <windows.h>

using namespace std;

int main(){

double x;

cout << "how old are you?" << endl;
cin >> x;
cout << "so you are " << x << " years old"

system("pause");
return 0;

}
 
cout << "so you are " << x << " years old"

missing semicolon ??
why are you using "conio.h" and "windows.h"?

also don't use system(); use
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>

using namespace std;

int main()
{

double x;

cout << "how old are you?" << endl;
cin >> x;
cout << "so you are " << x << " years old"

cin.get();
cin.get();

return 0;
}


instead
More using tips:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>

// Do not expose more from a namespace than absolutely necessary
using std::cout;
using std::cin;
using std::endl;

int main()
{

unsigned int x;  // Almost no-one is 3.14 years, or -7 years old.

cout << "how old are you?" << endl;
cin >> x;
cout << "so you are " << x << " years old"  << endl;

cin.get();
cin.get();

return 0;
}
Last edited on
Topic archived. No new replies allowed.