Understandable. Once I reach that stage, I'll begin to implement it into my source code. But until then, I'll have to deal with the bugs already in my program. For instance, the program tends to drop the first integer variable...All the time. It turns from what ever number the user inputs, to zero. Here's the code. There are no errors.
Code:
#include <iostream>
using namespace std;
int number1(char,int); //My first function
int number2(char,int);//My second function
int result(int,int);//My Third function
int num1,num2,;//Integer variables I will be using
char letter;//The variable that will contain the answer choices.
int main()
{
number1(letter,num1);//This is my first function call
cin.get();
return 0;
}
int number1(char letter, int num1)//This is the function being called and working in action.
{
cout<<"Please enter a number for num1.\n";
cin>> num1;
cin.ignore();
cout<<"You've entered "<< num1 <<" for num1. Is this correct?\n";
cout<<"Type'y' then enter for yes; 'n' then enter for no.\n";
cin>> letter;
cin.ignore();
if (letter == 'y')
{
number2(letter,num2);//This is the continuation of the function calls.
}
else
{
number1(letter,num1);//This is redirecting itself back to the function
} //so the number variable can be edited by the user.
}
int number2(char letter, int num2)//This is my function that has been called by the previous
{ //function.
cout<<"Please enter a number for num2.\n";
cin>> num2;
cin.ignore();
cout<<"You've entered "<< num2 <<" for num2. Is this correct?\n";
cout<<"Type 'y' then enter for yes; 'n' then enter for no.\n";
cin>> letter;
cin.ignore();
if (letter == 'y')
{
cout<<"Calculating results, please wait....\n";
result(num1,num2);//The final and last function.
}
else
{
number2(letter,num2);//Function calling itself to be edited by user.
}
}
int result(int num1, int num2)//Last function comparing to two integers.
{
if (num1 < num2)//I don't know where in the program exactly, but the integer for num1
{ //is somehow lost before here and turned into a zero.
cout<< num1 <<" is less than "<< num2 << ".\n";
}
else if (num1 == num2){
cout<< num1 <<" is equal to "<< num2<<".\n";
}
else
{ cout<< num1 <<" is greater than "<< num2<<".\n";
}
}