i am a newbie to c++

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
#include <iostream>
using namespace std;
using std::cout;
using std::endl;


int space(int& mass); // Function 
int main(void)
	
{
	int  velocity;
	int distance;
	int time;
int  mass=205; // mass of object
int  momentum=0;//speed of object
int  distance=1000;// distance
int result = space(mass);
cout << endl << "(mass*velocity) =" << result
<< endl << "(mass) = "<< mass;
result = (velocity);
cout << endl << "(velocity)=“ << result
<< endl << "value = " << endl;
for (int i = 1; i <2; ++i)
	cout << time << " ";
cout << "(velocity=distance/time) =" <<result
cout << " value = " << endl;


return 0;
}


// program does not work I do not know where I am going wrong 
// I do not want the answer but I need some gudiance. 
I do not know what your program is meant to do but errors I can see are: You need not declare that you are using std::cout and std::endl, if you have declared you are using std. Secondly your declaration for the function space should have a '*' not a '&'. And finally there is no implementation of the space function.
closed account (zb0S216C)
Script Coder wrote:
"Secondly your declaration for the function space should have a '*' not a '&'."

No, it's fine the way it is. An ampersand denotes either the address of something, or a reference to something. In this case, it's a reference to something.

Edit: On line 21, your double-quote () doesn't match the others.

Wazzak
Last edited on
closed account (N36fSL3A)
Would you like me to fix your code completely, clean it up so its more readable or both?

(This is was not intended to be rude in any way)
Last edited on by Fredbill30
closed account (N36fSL3A)
Are you going to answer?
Topic archived. No new replies allowed.