simiple fix... new to this stuff

im new to the C++ language and need a little help with line 15


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

#include <iostream>

void printMagSqrd (int x, int y);

int main()

{
	int x,y;
	std::cout << "\n Enter vector component values (x,y)" ;
	std::cin >> x >> y;
	
	int printMagSqrd;
	
	printMagSqrd (x,y);
	
	int mag = x*x + y*y;
	
	std::cout << "\n\n printMagSqrd = " << mag;

	return 0;

}




Last edited on
Please use the code tags (the # on the bar to the right) and put your code between them.

What is the actual problem?
well i have it working now... im not sure if everything makes since in it but here it is:

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

void printMagSqrd (int x, int y);

int main()

{
	int x;
	int y;
	std::cout << "Enter vector component values for x y: ";
	std::cin >> x >> y;
	
	int printMagSqrd;
		
	int mag = x*x + y*y;
	
	std::cout << "\n\n printMagSqrd = " << mag;
	std::cin >> printMagSqrd >> x >> y;
	return 0;

}
Last edited on
I know what the problem was (first version):
On line 4 you declared a function printMagSqrd().
On line 13 you declared an int printMagSqrd, which probably overrode the function.
On line 15 you called printMagSqrd(). You either got an error saying printMagSqrd isn't a function or the linker complained that you didn't implement the function.

I have a few questions about the second version:
What's printMagSqrd() for?
What's int printMagSqrd for?
Why do you input data one line before the end of the program?
Last edited on
Topic archived. No new replies allowed.