# Thread: help me with this simple script!

1. ## help me with this simple script!

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;
}

}

2. Yes no problem.... pretty much everything is done, all you need is another "if" statement that determines and checks the value of the RETURN statement that was returned from the function and after couple of "cout" 's and you're done....

for example

Code:
```OneOrTwo = evenorodd(dum);  // our function returns here  and
// assigns a return value to OneorTwo

if(OneOrTwo == 1)
cout << "The character is even!!! \n";

if(OneOrTwo == 2)
cout << "The character is odd!!! \n";

return 0;

// the end...```
Like I said you tutor helped you litterally to the end and he even put info down for you that should be followed to finish a program.
To be honest with you, this program doesn't involve much programming knowledge nor C++ for that matter, all it pretty much needs is some logical thinking......practice practice practice...

ADVICE: for the future try to approach every programming problem as a real life problem, and solve it on paper in plain English as you would be asked to give a verbal solution to a "human - real life" problem and then approach your computer and start programming...

Good Luck...

Regards,
matheo917

3. Hey the program works now, thanks for the advice! Next time I'll try to analyze it a little more from my perspective, thanks!