What am I doing wrong?

Just barely started on my C++ class, no help with anyone (it is an online course) and I'm just really confused. So any help would be grateful. This is what I have written.

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// assign1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
       std::cout << "Hello World \n";

       int firstNumber;
       int secondNumber=0;
       int result=0;
       float value1, value2;
       firstNumber=5;
       secondNumber=12;
       firstNumber=firstNumber+secondNumber-2;
       value1=2.5;
       value2=value1+3.5f;
       cout << "Here is value1: " << value1 << endl;
       cout << "Value1: " << value1 << " and Value2: " <<value2 << endl
       cout << "This program will add the 2 numbers that you'll provide.";
       cout << endl;

       cout << "Please enter one number: ";
       cin >> firstNumber;
       cout << endl;
       cout << "Please enter another number: ";
       cin >> secondNumber;
       cout << endl;

       result = firstNumber + secondNumber;
       cout << "Here is the result of our addition: " <<result <<endl;

       cout << endl;
       cout << "Please enter another number: ";
       cin >> secondNumber;
       cout << endl;

       result= firstNumber + secondNumber;
       cout << "Here is the result of our addition: " <<result <<endl;

       return 0;
}


this is what i'm trying to get
http://f.cl.ly/items/3f133V3l330z1d1p300k/Screen%20Shot%202011-09-14%20at%203.47.28%20AM.png
Last edited on
First of all - use [ code ] [ /code ] tags around your code posts here.

Next, please state what your actual problem is - don't just post a bunch of code and tell us "it doesn't work".
Sorry. When I try to build without debugging, I keep getting an error saying "There were some build errors. Would you like to continue and run the last successful build?"

https://docs.google.com/viewer?a=v&pid=explorer&chrome=true&srcid=0B5hPa_Y3W8JZMGVjMjNjMGUtMGE3Zi00MzNiLThkYzktMzJjMjA3NWZiZjA5&hl=en

This is the assignment im working on, starting page 9 labeled section 2.
You should have a section that says "console output" or something similar in your IDE - there should be a bunch of error messages that tell you exactly why the build failed. Post these here if you don't understand them.

Also, please tell us what IDE and what compiler/linker you are using.

For the record, I can already spot at least 1 error in your code, I am just not telling you yet so you get some practice in how to provide useful information for us, and also how you can find errors yourself.
Last edited on
From his error message I would guess he is using Visual C++ and as far as I can see there is only one error in the program (which I am not telling as I consider hanst99's point to be fair enough...)
closed account (1vRz3TCk)
I can see one error as well but I'm not going to tell you that it is on line 24....D'oh!

Edit:
That was meant to be D'oh not Duh...sorry for any confusion.
Last edited on
Great, you totally ruined it.
I'm on Linux, so I changed the head to
1
2
3
4
5
#include <iostream>

using namespace std;

int main(int argc, char* argv[])

And get a very clean message what and where the error. (Only one and it's just a typo).
Come on folks, you don't all need to come here and brag about how you found the error. It's really not that hard. Just wait til the OP returns.
I just promote Linux. :-)
Just wait til the OP returns.

I've been seeing this reference to OP a lot on this forum lately. The only meanings for OP that I know of is Over-Powered and Operator (in Minecraft). What are you referring to?
Original Poster.
Haha. Alright. Thanks. :P
Topic archived. No new replies allowed.