Geting wrong output at wery basic prog.

Hello all and thanks to everyone that will take the time to help me out.
And to you other lassy ppl that just clicked on this :).

Ok so to the point am just starting out whit C++ and i have run upon a litel snag.
I`am at http://www.learncpp.com/cpp-tutorial/17-forward-declarations/
And am trying to solve "2) Write the function prototype for this function:"

So this is my code:
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
// functionprototype.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

int DoMath(int first, int second, int third, int fourth)
{
     return first + second * third / fourth;
}

int main()
{
	using namespace std;

	cout << "Enter Number: ";
	int first;
	cin >> first;

	cout << "Add +: ";
	int second;
	cin >> second;

	cout << "Multiply it by? *: .?" ;
	int third;
	cin >> third;

	cout << "And Divide it by /: ";
	int fourth;
	cin >> fourth;
	cout << "And then you get: " << endl;
	cout << DoMath << endl;
	return 0;
}


It works all good down to the last line.
It outputs:

Enter Number: 2
Add +: 5
Multiply it by? *: .?4
And Divide it by /: 2
And then you get:
00A4120D
Press any key to continue . . .

As you shurly allready guest the answer shude not be: 00A4120D.
So is there sombody that can please tell me what i did wrong?

And am sorry for my bad gramma.
I realy try but i know its not good, thanks for bering whit me.
You're outputting a function pointer, so it's printing the address of the function.

To call a function you need to use parenthesis and pass the appropriate data.

Line 32 should look like this:

 
cout << DoMath(first,second,third,fourth) << endl;
Oki thanks Disch :D
It works! :p
I tryd almost that just like this instead
" cout << DoMath(first, second, third, fourth) << endl; "
So gues the spaces killed the cat :p.
thanks again...

Status: Solved
The spaces mean nothing. That would work just fine.

You must have had something else wrong before ;P
Topic archived. No new replies allowed.