I have been working on this program to count the number of zero's odd, and even numbers that a user inputs. I have tried different variations and cannot get it to go, I keep getting linker errors and cannot see where the problem is. I am new to this and could really use the help.

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

void ClassifyNum(long remainder, long& countZero, long& countOdd, long& countEven );
void GetNum(long& num);
void Start(long remainder,long& countZero, long& countOdd, long& countEven);

using namespace std;


int main( )
	{
	long number;
	int numCounter;
	int userInput;
	long zero;
	long odd;
	long even;
	long remainder;
	char userAnswer;



do{
	Start(remainder,zero, odd, even);
	cout << "Please enter an number. " << endl;
	cin >> userInput;

	for (numCounter = 1; numCounter <= userInput;numCounter++)
	{
		GetNum(number);
		cout << number << " ";
		ClassifyNum(remainder, zero, odd, even);
	}
	cout << endl;
	cout << "Go again? (y/n). ";
	cin >> userAnswer;
	cout << endl;
}while(userAnswer=='y');
	return 0;
}

void start(long remainder,long& countZero, long& countOdd, long& countEven)
	{
		remainder = 0;
		countZero = 0;
		countEven = 0;
		countOdd = 0;
	}

	void GetNum(long& num)
	{
		cin >> num;
	}
	void ClassifyNum(long remainder, long& countZero, long& countOdd, long& countEven)
	{	if (remainder == 0)
		countZero++;
		else if (remainder%2 == 0)
			countEven++;
		else
			countOdd++;
	}

Recommended Answers

All 3 Replies

your function prototype :

void Start(long remainder,long& countZero, long& countOdd, long& countEven);

your function defintion :

void start(long remainder,long& countZero, long& countOdd, long& countEven)

The 's' is not capitalize in the second one. Also I do not see any point
for makeing this function. Also you forgot '&' before the remainder variable.

What is your linker error? I was able to get it to compile for me by changing the s in start (the definition) to S.

Are you trying to compile this in VC++ 2008? If you chose a blank project it might be giving you guff about it.

Also, and this doesn't matter as much as the other stuff, but are you doing anything with your counts? You don't display them...

What is your linker error? I was able to get it to compile for me by changing the s in start (the definition) to S.

Are you trying to compile this in VC++ 2008? If you chose a blank project it might be giving you guff about it.

Also, and this doesn't matter as much as the other stuff, but are you doing anything with your counts? You don't display them...

I found the S and the little s. Also, what its supposed to do, is take the user input number like 890, and return one positive, one negative and one zero. I also forgot to put a print function in the code, so now I' try that. Thanks for the assistance

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.