Struggling with finishing this assignment

Im getting 3 c4716 errors in my code and I don't know what to do

[code]
#include "stdafx.h"
#include <iostream>
using namespace std;

// Global variable
int num;
int input;
// Function declaration
int& EnterLimit();
int PrintMenu(int num1);
int& EnterOption();
int PrintSeries(int num2, int num3);
int SelectSeries();
int main() //main function
{
EnterLimit(); //calling EnterLimit function
PrintMenu(num); //calling PrintMenu function
cout << "\n"; //printing Enter or in oher wordrs end of line
SelectSeries(); // calling SelectSeries function
return 0; // End of main function
}

int& EnterLimit() //EnterLimit Fuction int& so that we can pass by reference
{
cout << "Enter a Integral number from 1 - 32767 : "; // vale of int is from -32767 to 32767
cin >> num; //input from user limit of series
return num; //return
}

int PrintMenu(int num)
{
cout << "1 " << "Print all the numbers between 1 and N that are divisible by 1 ";
int i = 1; // i=1
while (i <= num) // loop for cheking i value
{
cout << i; // print i
i++; // i=i+i
}
cout << "\n";
cout << "2 " << "Print all the numbers between 1 and N that are divisible by 2 ";
int j = 1;
while (j <= num)
{
if (j % 2 == 0) //if j / 2 =0 then only print
cout << j;
j++;
}
cout << "\n";
cout << "3 " << "Print all the numbers between 1 and N that are divisible by 3 ";
int k = 1;
while (k <= num)
{
if (k % 3 == 0)
cout << k;
k++;
}
cout << "\n";
cout << "4 " << "Print all the numbers between 1 and N ";
int l = 1;
while (l <= num)
{
cout << l;
l++;
}
cout << "\n";
cout << "5 " << "Print all the even numbers between 1 and N ";
int m = 1;
while (m <= num)
{
if (m % 2 == 0)
cout << m;
m++;
}
cout << "\n";
cout << "6 " << "Print all the even numbers between 1 and N ";
int n = 1;
while (n <= num)
{
if (n % 2 != 0)
cout << n;
n++;
}
}

int& EnterOption()
{
int check = 0;
while (check == 0)
{
cout << "Enter 1 2 3 4 5 6 or 0 to Exit";
cin >> input;
if (input == 1 || input == 2 || input == 3 || input == 4 || input == 5 || input == 6 || input == 0) // validating input
check = 1;
}
return input; //returning input
}
int PrintSeries(int input, int num)
{

if (input == 1)
{
int i = 1;
while (i <= num)
{
cout << i;
i++;
}
}
cout << "\n";
if (input == 2)
{
int j = 1;
while (j <= num)
{
if (j % 2 == 0)
cout << j;
j++;
}
}
cout << "\n";
if (input == 3)
{
int k = 1;
while (k <= num)
{
if (k % 3 == 0)
cout << k;
k++;
}
}
cout << "\n";
if (input == 4)
{
int l = 1;
while (l <= num)
{
cout << l;
l++;
}
}
cout << "\n";
if (input == 5)
{
int m = 1;
while (m <= num)
{
if (m % 2 == 0)
cout << m;
m++;
}
}


cout << "\n";
if (input == 6)
{
int n = 1;
while (n <= num)
{
if (n % 2 == 0)
cout << n;
n++;
}
}
cout << "\n";
}
int SelectSeries()
{
EnterOption();
cout << "\n";
PrintSeries(input, num);
while (input != 0)
{
EnterOption();
cout << "\n";
PrintSeries(input, num);

}
}
To be more specific, "'PrintMenu' 'PrintSeries' and 'SelectSeries': must return a value" comes up when I build the solution
May I say it looks pretty obvious?

1
2
3
4
5
int& EnterLimit();
int PrintMenu(int num1);
int& EnterOption();
int PrintSeries(int num2, int num3);
int SelectSeries();

Here you state all your functions must return an int, some of them by copy, some as a reference.

1
2
3
// Global variable
int num;
int input;

Here you declare your variables as global (bad habit!).
So, they need neither to be passed nor to be returned.

And, as a matter of fact, neither PrintMenu() nor PrintSeries() nor SelectSeries() returns anything. Therefore the compiler complains.
Last edited on
Topic archived. No new replies allowed.