I am building a program and once a certain "else" is "activated", I want the program to not go to the other function. So if the else in Function1 is used, dont go to function2. For example:
//not written perfectly, but you'll get the point
Function1()
{
if(a = 2 * 100)
{
b = a + 100 ;
}
else
{
cout << a << " does not equal 200" << endl;
system ("PAUSE") ;
//the pause only pauses the program, not stop the function2, so when enter is
//pressed, the program then displays function2
// in this else statement, I want the program to not go to Function2 and to just display the cout, pause, and //end
}
return b;
}
Function2()
{
//do something with b
}
int main()
{
function1(0)
function2(0)
}
I want, at the else statement if it is used to then have the program skip function2. To do this, do I need to have if and else statements in the int main or is there another way?
Any feedback will be appreciated! Thank you!
function1(int x, int & cheeto){ //Notice the & symbol. You have to put it there.
if (//......){
//some code......cheeto is NOT changed.
}
else{
//some code......
cheeto = 2;//Change it to a random value.
//So in main(), cheeto is now 2. The second function will not run.
}
}
int main(){){
int cheeto = 1;
function1(0, cheeto);
//If cheeto still equaled 1, then the "else" in function1 did not execute.
if (cheeto == 1){
function2(0);
}
}