Void and return functions with loops

I'm taking an intro to C++ class and am having a little bit of trouble with this program. However I'm having a small problem with financial aid that is preventing me from purchasing the book for this class for another week and a half, and I don't want to fall behind on the homework so I'm here asking for help.

What I'm supposed to do: Create a void function with a pre-test loop that receives an integer parameter by value. The pre-test loop displays all the numbers from 1 to the parameter, the function should be called in Main.

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

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{	
	int OneTen();
	system("pause");	
	return 0;
}
void OneTen (int high, int num1)
{
	high = 10;
	num1 = 0;
	while (num1 < high)
	{
		cout << num1 << " ";
		num1 += 1;
	}
}

When I run it, it runs without error but I get no output.

Along with this I have two other problems to do in the same program, that I haven't gotten to yet since I can't get the first.

2) Create an integer return function - recieves an int parameter by reference (I'm not sure how to do this). It should display all the even numbers from two through parameter. Call this function in main with a parameter if 14, also in Main print the function call’s parameter after the call. Return the parameter.

3)Create an integer return function - receives an integer parameter by value. Using a do while loop, display all the ODD numbers between one and parameter, using a CONTINUE to skip over 5. Call it in main with a parameter of 21. Also in main print the parameter call and return the parameter.

Thanks in advance for any help at all, as I said, I can't get the book for at least another week or more and can't afford to fall behind.
For your first issue:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "stdafx.h"
#include <iostream>

using namespace std;

void OneTen ( int );     //you have to prototype your function before calling it - notice ;
                         //and you only need to pass 1 integer value to it as you stated

int _tmain(int argc, _TCHAR* argv[])
{	
	OneTen( 10 );        //when calling the function you do not need to use it's return type - using 10 as an example
	system("pause");	
	return 0;
}

void OneTen ( int high )  //here you have to name the variable that is going to store the value
{
	int num1 = 0;
	while (num1 < high)
	{
		cout << num1 << " ";
		num1 += 1;
	}
}


I hope it helps you somehow with functions.
Thanks! That got the void function to work, but I'm a little lost on how the return functions work still, and utterly and completely lost about CONTINUE.
Topic archived. No new replies allowed.