can you help why wont this compile? help

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "stdafx.h" // This is for MY compiler remove this if the program does not compile.
#include <iostream>
using namespace std;

int main()
{
	int num1,num2;
	int answer;

	cout << "Enter numbers";
	cout ":\n";
	cin >> num1;
	cout ":\n";
	cin >> num2;
    cout << "1.adding";
	cin.get();

if (answer == 1)
{
  cout << endl;
  cout << "(Simple Addition) " << endl;
  cout << "Please enter first number: ";
  cin  >> num1;
  cout << "Please enter second number: ";
  cin  >> num2;
  cout << endl;

  cout << num1 << " + " << num2 << " = " << num1 + num2 << endl << endl;
  cin.get();
}

}


error code

------ Build started: Project: calculator 2.0, Configuration: Debug Win32 ------
calculator 2.0.cpp
calculator 2.0.cpp(11): error C2143: syntax error : missing ';' before 'string'
calculator 2.0.cpp(13): error C2143: syntax error : missing ';' before 'string'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
On lines 11 and 13, you forgot the << after cout.
You forgot the left stream operator on lines 11 and 13. (<<)

answer variable on line 18 is being used but you never initialiazed it, meaning that it will contain garbage.
wow thats embarrassing um thanks i will be more careful to be fair it is 4:00 am were i am.lol
everyone goes through a less useful post now and then, I surely have contributed with my share of them. ;)
closed account (zb0S216C)
You can omit the stdafx header by deselecting the Pre-compiled headers box. If you've already built the project, you can simply disable it through Project Options.

Wazzak
Topic archived. No new replies allowed.