Chase Payne Grandmaster Cheater
Reputation: 1
Joined: 20 Mar 2008 Posts: 533
|
Posted: Thu Aug 20, 2009 5:59 pm Post subject: Vairables not registering? C++ [Solved] |
|
|
>.> this is my second day on learning C++ ( I don't know charter strings YET)
But how do I get this to work correctly? All it does is return 0-0, 0+0... etc.
| Code: | #include "stdafx.h"
#include <iostream>
int X;
int Y;
int checker();
int chChoice;
char YNyes;
int main()
{
using namespace std;
cout << "Enter a value: ";
cin >> X;
cout << "Enter a second value: ";
cin >> Y;
checker();
}
int checker()
{
using namespace std;
cout << "\nEnter one of the following: +, -, *, or /";
char chChoice;
cin >> chChoice;
if (chChoice == '+')
{
cout << X << " + " << Y << " is " << (X + Y) << endl;
cout << "Would you like to enter another equation!?\n Enter as Y/N.\n";
char YNyes;
cin >> YNyes;
if (YNyes == 'y')
main();
else
cout << "\nOkay, you made it clear you don't\n";
return 0;
}
if (chChoice == '-')
{
cout << X << " - " << Y << " is " << (X - Y) << endl;
cout << "Would you like to enter another equation!?\n Enter as Y/N.\n";
char YNyes;
cin >> YNyes;
if (YNyes == 'y')
main();
else
cout << "\nOkay, you made it clear you don't\n";
return 0;
return 0;
}
if (chChoice == '*')
{
cout << X << " * " << Y << " is " << (X * Y) << endl;
cout << "Would you like to enter another equation!?\n Enter as Y/N.\n";
char YNyes;
cin >> YNyes;
if (YNyes == 'y')
main();
else
cout << "\nOkay, you made it clear you don't\n";
return 0;
}
if (chChoice == '/')
{
cout << X << " / " << Y << " is " << (X / Y) << endl;
cout << "Would you like to enter another equation!?\n Enter as Y/N.\n";
char YNyes;
cin >> YNyes;
if (YNyes == 'y')
main();
else
cout << "\nOkay, you made it clear you don't\n";
return 0;
return 0;
}
else
{
cout << "Sorry, invalid character.\t\t\t\t";
checker();
return 0;
}
}
|
Nevermind, I found the problem
I used double x and y twice by accident... after declaring it lol
|
|