Hello, I just began doing c++ today, and i've done a program like this:
#include <iostream>
using namespace std;
int main()
{
int num1;
int num2;
int valinta;
int valinta2;
cout<<"Haluatko pelata pelia? 1.Kylla 2.En\n";
cin>>valinta;
if(valinta == 1){
cout<<"Paljonko on 3+2: ";
cin>>num1;
cin.ignore();
if(num1 == 5){
cout<<"Aivan oikein, mutta paljonko on 5*5: ";
cin>>num2;
cin.ignore();
if(num2 == 25){
cout<<"Profeetta. Uudestaan? 1. Kylla 2. Ei\n";
cin>>valinta2;
if(valinta2 == 1){
return valinta;
}
}
}
else if(valinta == 2){
}
else{
cout<<"Oletko todella noin paska?\n";
}
cin.get();
}
}
You can see theres "return valinta;", because in the last IF, if the user writes 1, it will go back to beginging. But I cant get it work. If someone could please tell me how to do it, I woulda be really happy.