Ok, this is a class project and my tutor helped me get this far however I'm stumped on how to finish, suggestions? I'm VERY new to C++!
#include <iostream>
using namespace std;
int evenorodd(char);
int main() // main
{
char dum; // This character is going to be sent to another function
// which will determain if it's odd or even
int OneOrTwo; //will either be 1 or 2, 1 if character is even, 2 if charcter is
//odd
cout << "Please enter a number between 0 and 9: ";
cin >> dum;
OneOrTwo = evenorodd(dum);
//if OneOrTwo is 1 then character was even
//if OneOrTwo is 2 then character was odd
return 0;
}
//what the function does
int evenorodd(char dum1)
{
//if char mod 2 = 0 then number is even so we return 1
if ((dum1 % 2) == 0)
{
return 1;
}
//if char mod 2 = 1 then number is odd so we return 2
else if ((dum1 % 2) == 1)
{
return 2;
}
}



LinkBack URL
About LinkBacks


