Can somebody help me with this code. The program need to repeat until the user wants to quit.

#include<conio.h>
#include<iostream>
#include <cstdlib>
#include <stdlib.h>
using namespace std;

int opcio1();
int opcio2();
int opcio3();


 
int main()
{
  int choice;
cout << "==========================================" << endl;
cout << " Menu" << endl;
cout << "==========================================" << endl;
cout << "1.Fortune Teller" << endl;
cout << "2.Stock Market" << endl;
cout << "==========================================" << endl;
 
cout<<"For fortune teller press 1, for stock market press 2"<<endl;
cin>>choice;
      if (choice == 1) opcio1();      
      else if (choice == 2) opcio2();      
      else cout << "Use only number shown in the menu" << endl;  
      

  
}

int opcio1()//Stock Market
{
	char sentence[100];	
	cout<<"Ask what you should do in the market today!"<<endl;
	cin.getline (sentence,100);
	cin.ignore();
	int theNumber;
	theNumber = 1 + rand() % 3;
			
	switch (theNumber)  
	{        
		case 1:                        
			cout<<"You should definetly buy!"<<endl;                     
			break;

		case 2:
			cout<<"Sell!Sell!Sell!"<<endl;
			break;
		case 3:
			cout<<"Heck if I know. Go ask your brocker."<<endl;
			break;
		default:
			break; 
	}
			 
		system("cls");
		return opcio3();
 }

int opcio2()//Fortune teller
{
	char sentence[100];
	cout<<"Do you feel lucky today!"<<endl;
	cin.getline (sentence,100);
	cin.ignore();
	int theNumbers;
	theNumbers = 1 + rand() % 4;
	
	if (theNumbers == 1)
	{
		cout<<"No way!"<<endl;
	}
	else if (theNumbers == 2)
	{
		cout<<"Most Likely, yes!"<<endl;
	}
	else if (theNumbers ==3)
	{
		cout<<"Try again tomorrow!"<<endl;
	}
	else if (theNumbers == 4)
	{
		cout<<"Yes. I belive so!"<<endl;
	}

	system("cls");
		return opcio3();
}
int opcio3()
{
int choice1;

cout<<"If you want to exit press 1, for starting over press 2"<<endl;
cin>>choice1;
      	       
      if (choice1 == 1) exit(-1);
	  else if(choice1 == 2) main(); 
	  else cout << "Use only number shown in the menu" << endl;
	  	
}

Hi, I would do this:
cout<<"For fortune teller press 1, for stock market press 2"<<endl;
cin>>choice;
if (choice == 1) opcio1();
else if (choice == 2) opcio2();
else if (choise == 3) return 0;
else cout << "Use only number shown in the menu" << endl;

It doesn't help me. I need after running the fortune teller or stock market to ask a question
Do you want to exit or star again. But after running the fortune teller or stock market

int main()
{ // main began
  int choice = 0;
  int sentinela = 0; // initialize
cout << "==========================================" << endl;
cout << " Menu" << endl;
cout << "==========================================" << endl;
cout << "1.Fortune Teller" << endl;
cout << "2.Stock Market" << endl;
cout << "==========================================" << endl;
 
cout<<"For fortune teller press 1, for stock market press 2"<<endl;
cin>>choice;
do{ // do began    
      if (choice == 1) opcio1();      
      else if (choice == 2) opcio2();      
      else cout << "Use only number shown in the menu" << endl;  

cout << "Do you want to exit? Please enter a negative number" << endl;      
cin >> sentinela;
} while (sentinela > 0); // while sentinela be greater than 0, repeat do 
  
} // main end

That should work...

It doesn't help me. I need after running the fortune teller or stock market to ask a question
Do you want to exit or star again. But after running the fortune teller or stock market

Please use code tags with [ CODE = C++]
//Here code
[ /CODE ]

that would be really easy. just put your main idea in a while loop and switch
it would be make it loop time and again until the sentinel value.

CODE

That should work...

You should try testing your code before posting. That way you can actually say "that will work", and your code will in fact work. What you posted is an useless loop, so it can't possibly work...

And use CODE tags! Read the Rules.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.