whats wrong?

Sep 2, 2013 at 5:09am

#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;

}
Sep 2, 2013 at 5:20am
 
cout << "so you are " << x << " years old"

missing semicolon ??
Sep 2, 2013 at 5:43am
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
Sep 2, 2013 at 8:48am
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 Sep 2, 2013 at 8:48am
Topic archived. No new replies allowed.