hi guys,i was trying to make user able to make selection again when they make an invalid input, but when i run this code,it just doesnt work that way,it goes printing the same line like crazy...did i do something wrong?

int main (void)


{	
//Local Declarations
	int menu;
	

//Statements

	time_t mytime;
	mytime = time(NULL);
	printf(ctime(&mytime));
	printf("\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
	printf("\t\t@   WELCOME TO CHEMY'S CHEMISTRY   @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@            MAIN MENU             @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@   1. CHEMISTRY QUIZ              @\n");
	printf("\t\t@   2. IDEAL GAS LAW CALCULATOR    @\n");
	printf("\t\t@   3. OPTIONAL GAME               @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@   0. EXIT                        @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n");
	
	printf("Please choose your menu: ");
	scanf("%d", &menu);
	while(menu != 0)
	
	{
	switch(menu)
	{
	case 1: quiz();
        break; 
	case 2: calculator();
        break;
	case 3: optional();
        break;
	case 0: printf("Goodbye\n");
        break;
	default: printf("I'm sorry, but you have enter an invalid selection. Please try again.\n\n");	
			 printf("Please choose your menu: ");
			 scanf("%d", &menu);
        break;
	}}

	return 0;

}

Recommended Answers

All 12 Replies

put the user input lines inside the loop otherwise the value of menu will never change

still, the line printf("I'm sorry, but you have enter an invalid selection. Please try again.\n\n"); is repeated again and again very fast when user input an invalid value

int main (void)


{	
//Local Declarations
	int menu;
	

//Statements

	time_t mytime;
	mytime = time(NULL);
	printf(ctime(&mytime));
	printf("\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
	printf("\t\t@   WELCOME TO CHEMY'S CHEMISTRY   @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@            MAIN MENU             @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@   1. CHEMISTRY QUIZ              @\n");
	printf("\t\t@   2. IDEAL GAS LAW CALCULATOR    @\n");
	printf("\t\t@   3. OPTIONAL GAME               @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@   0. EXIT                        @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n");
	
	printf("Please choose your menu: ");
	scanf("%d", &menu);
	switch(menu)
	{
	case 1: quiz();
        break; 
	case 2: calculator();
        break;
	case 3: optional();
        break;
	case 0: printf("Goodbye\n");
        break;

	}


	while(menu != 0)
	{
		printf("I'm sorry, but you have enter an invalid selection. Please try again.\n\n");	
		printf("Please choose your menu: ");
		scanf("%d", &menu);

	switch(menu)
	{
	case 1: quiz();
        break; 
	case 2: calculator();
        break;
	case 3: optional();
        break;
	case 0: printf("Goodbye\n");
        break;

	}
	}

	return 0;

}

remove the printf() at line 32 and put it as a default case and don't forget the break if it's not the last case
also menu can only take an int value

Edit: just use a single switch statement and a single loop on it and put the user input at the beginning of the loop
and this line:

printf("I'm sorry, but you have enter an invalid selection. Please try again.\n\n");

should be the default case

Put line 32 in the default clause of the switch statement.
Remove lines 28&29
set menu to a starting value, other then 0.

remove the printf() at line 32 and put it as a default case and don't forget the break if it's not the last case
also menu can only take an int value

Edit: just use a single switch statement and a single loop on it and put the user input at the beginning of the loop
and this line:

printf("I'm sorry, but you have enter an invalid selection. Please try again.\n\n");

should be the default case

im sorry,i dont get it, is this what u mean?

int main (void)


{	
//Local Declarations
	int menu;
	

//Statements

	time_t mytime;
	mytime = time(NULL);
	printf(ctime(&mytime));
	printf("Author: Pung Kah Heng, Seven Lim Xian Wen, Ng Wan Yee, Ernest Lee Yik Hieng\n\n\n");
	printf("\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
	printf("\t\t@   WELCOME TO CHEMY'S CHEMISTRY   @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@            MAIN MENU             @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@   1. CHEMISTRY QUIZ              @\n");
	printf("\t\t@   2. IDEAL GAS LAW CALCULATOR    @\n");
	printf("\t\t@   3. OPTIONAL GAME               @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@   4. EXIT                        @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n");
	
	printf("Please choose your menu: ");
	scanf("%d", &menu);
	switch(menu)
	{
	case 1: quiz();
        break; 
	case 2: calculator();
        break;
	case 3: optional();
        break;
	case 4: printf("Goodbye\n");
        break;
	default: printf("I'm sorry, but you have enter an invalid selection. Please try again.\n\n");	
		break;

	}


	while(menu != 4)
	{
	printf("Please choose your menu: ");
	scanf("%d", &menu);

	switch(menu)
	{
	case 1: quiz();
        break; 
	case 2: calculator();
        break;
	case 3: optional();
        break;
	case 4: printf("Goodbye\n");
        break;
	default: printf("I'm sorry, but you have enter an invalid selection. Please try again.\n\n");	
		break;

	}}
	return 0;

}

im sorry,i dont get it, is this what u mean?

At your last code lines 28-43 are unnecessary

but without line 28-29, the error comes up says variable 'menu' is being used without being defined...i think its easier if i give u full code and you can try run it to see whats wrong,thanks :D

#include <stdio.h>
#include <conio.h>
#include <time.h>



//Function Declarations
void quiz (void);
void calculator (void);
void optional (void);
void pressure (void);
void volume (void);
void mol (void);
void temperature (void);
void hangman (void);


int main (void)


{	
//Local Declarations
	int menu;
	

//Statements

	time_t mytime;
	mytime = time(NULL);
	printf(ctime(&mytime));
	printf("Author: Pung Kah Heng, Seven Lim Xian Wen, Ng Wan Yee, Ernest Lee Yik Hieng\n\n\n");
	printf("\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
	printf("\t\t@   WELCOME TO CHEMY'S CHEMISTRY   @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@            MAIN MENU             @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@   1. CHEMISTRY QUIZ              @\n");
	printf("\t\t@   2. IDEAL GAS LAW CALCULATOR    @\n");
	printf("\t\t@   3. OPTIONAL GAME               @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@   4. EXIT                        @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n");
	
	printf("Please choose your menu: ");
	scanf("%d", &menu);
	switch(menu)
	{
	case 1: quiz();
        break; 
	case 2: calculator();
        break;
	case 3: optional();
        break;
	case 4: printf("Goodbye\n");
        break;
	default: printf("I'm sorry, but you have enter an invalid selection. Please try again.\n\n");	
		break;

	}


	while(menu != 4)
	{
	printf("Please choose your menu: ");
	scanf("%d", &menu);

	switch(menu)
	{
	case 1: quiz();
        break; 
	case 2: calculator();
        break;
	case 3: optional();
        break;
	case 4: printf("Goodbye\n");
        break;
	default: printf("I'm sorry, but you have enter an invalid selection. Please try again.\n\n");	
		break;

	}}
	return 0;

}


//quiz

		
void quiz (void)
{	
	char back;
	char answer;
	int score = 0;
	
	//Question 1
	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*  Welcome to try CHEMY's CHEMISTRY QUIZ... Are you ready for it???  *\n");
	printf("\t**********************************************************************\n");
	printf("\n\n\nQuestion 1\n\n");
	printf("A balloon contains 4 moles of an ideal gas with a volume of 5.0 L.If an\n"); 
	printf("additional 8 moles of the gas is added at constant pressure and \n");
	printf("temperature, what will be the final volume of the balloon?\n");
	printf("<a> 15L\n");
	printf("<b> 30L\n");
	printf("<c> 45L\n");
	printf("<d> 60L\n");
	printf("\nPlease key in your answer: ");
	scanf(" %c", &answer);

	if (answer == 'a')
	{score++;}

	//Question 2
	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*  Welcome to try CHEMY's CHEMISTRY QUIZ... Are you ready for it???  *\n");
	printf("\t**********************************************************************\n");
	printf("\n\n\nQuestion 2\n\n");
	printf("What is the density (in g/L) of a gas with a molar mass of 60 g/mol\n"); 
	printf("at 0.75 atm and 27 °C?\n");
	printf("<a> 1.83 g/L\n");
	printf("<b> 1.93 g/L\n");
	printf("<c> 2.83 g/L\n");
	printf("<d> 2.93 g/L\n");
	printf("\nPlease key in your answer: ");
	scanf(" %c", &answer);

	if (answer == 'a')
	{score++;}

	//Question 3
	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*  Welcome to try CHEMY's CHEMISTRY QUIZ... Are you ready for it???  *\n");
	printf("\t**********************************************************************\n");
	printf("\n\n\nQuestion 3\n\n");
	printf("A mixture of helium and neon gases is held in a container at 1.2 atmospheres.\n"); 
	printf("If the mixture contains twice as many helium atoms as neon atoms, what is the\n");
	printf("partial pressure of helium?\n");
	printf("<a> 0.6 atm\n");
	printf("<b> 0.7 atm\n");
	printf("<c> 0.8 atm\n");
	printf("<d> 0.9 atm\n");
	printf("\nPlease key in your answer: ");
	scanf(" %c", &answer);

	if (answer == 'c')
	{score++;}

	//Question 4
	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*  Welcome to try CHEMY's CHEMISTRY QUIZ... Are you ready for it???  *\n");
	printf("\t**********************************************************************\n");
	printf("\n\n\nQuestion 4\n\n");
	printf("4 moles of nitrogen gas are confined to a 6.0 L vessel at 177 °C and \n"); 
	printf("12.0 atm. If the vessel is allowed to expand isothermically to 36.0 L, \n");
	printf("what would be the final pressure?\n");
	printf("<a> 5.0 atm\n");
	printf("<b> 24.0 atm\n");
	printf("<c> 12.0 atm\n");
	printf("<d> 2.0 atm\n");
	printf("\nPlease key in your answer: ");
	scanf(" %c", &answer);

	if (answer == 'd')
	{score++;}


	//Question 5
	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*  Welcome to try CHEMY's CHEMISTRY QUIZ... Are you ready for it???  *\n");
	printf("\t**********************************************************************\n");
	printf("\n\n\nQuestion 5\n\n");
	printf("A 9.0 L volume of chlorine gas is heated from 27 °C to 127 °C at constant\n"); 
	printf("pressure. What is the final volume?\n");
	printf("<a> 1.0 L\n");
	printf("<b> 2.0 L\n");
	printf("<c> 3.0 L\n");
	printf("<d> 4.0 L\n");
	printf("\nPlease key in your answer: ");
	scanf(" %c", &answer);

	if (answer == 'b')
	{score++;}

	//Question 6
	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*  Welcome to try CHEMY's CHEMISTRY QUIZ... Are you ready for it???  *\n");
	printf("\t**********************************************************************\n");
	printf("\n\n\nQuestion 6\n\n");
	printf("The temperature of a sample of an ideal gas in a sealed 5.0 L container is\n"); 
	printf("raised from 27 °C to 77 °C. If the initial pressure of the gas was 3.0 atm,\n");
	printf("what is the final pressure?\n");
	printf("<a> 3.4 atm\n");
	printf("<b> 2.4 atm\n");
	printf("<c> 3.5 atm\n");
	printf("<d> 2.5 atm\n");
	printf("\nPlease key in your answer: ");
	scanf(" %c", &answer);

	if (answer == 'c')
	{score++;}

	//Question 7
	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*  Welcome to try CHEMY's CHEMISTRY QUIZ... Are you ready for it???  *\n");
	printf("\t**********************************************************************\n");
	printf("\n\n\nQuestion 7\n\n");
	printf("A 0.614 mole sample of ideal gas at 12 °C occupies a volume of 4.3 L."); 
	printf(" What is the pressure of the gas?\n");
	printf("<a> 3.0 atm\n");
	printf("<b> 3.1 atm\n");
	printf("<c> 3.2 atm\n");
	printf("<d> 3.3 atm\n");
	printf("\nPlease key in your answer: ");
	scanf(" %c", &answer);

	if (answer == 'd')
	{score++;}

	//Question 8
	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*  Welcome to try CHEMY's CHEMISTRY QUIZ... Are you ready for it???  *\n");
	printf("\t**********************************************************************\n");
	printf("\n\n\nQuestion 8\n\n");
	printf("Helium gas has a molar mass of 2 g/mol. Oxygen gas has a molar mass of \n");
	printf("32 g/mol.How much faster or slower would oxygen effuse from a small \n"); 
	printf("opening than helium?\n");
	printf("<a> Oxygen would effuse 1/4 as fast as helium (rO = 0.25 rHe)\n");
	printf("<b> Oxygen would effuse 1/2 as fast as helium (rO = 0.25 rHe)\n");
	printf("<c> Helium would effuse 1/4 as fast as oxygen (rO = 0.25 rHe)\n");
	printf("<d> Helium would effuse 1/2 as fast as oxygen (rO = 0.25 rHe)\n");
	printf("\nPlease key in your answer: ");
	scanf(" %c", &answer);

	if (answer == 'd')
	{score++;}


	//Question 9
	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*  Welcome to try CHEMY's CHEMISTRY QUIZ... Are you ready for it???  *\n");
	printf("\t**********************************************************************\n");
	printf("\n\n\nQuestion 9\n\n");
	printf("What is the average velocity of nitrogen gas molecules at STP? Molar mass\n");
	printf("of nitrogen = 14 g/mol\n");
	printf("<a> 291.34 m/s\n");
	printf("<b> 493.15 m/s\n");
	printf("<c> 12.42 m/s\n");
	printf("<d> 21.57 m/s\n");
	printf("\nPlease key in your answer: ");
	scanf(" %c", &answer);

	if (answer == 'b')
	{score++;}


	//Question 10
	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*  Welcome to try CHEMY's CHEMISTRY QUIZ... Are you ready for it???  *\n");
	printf("\t**********************************************************************\n");
	printf("\n\n\nQuestion 10\n\n");
	printf("A 60.0 L tank of chlorine gas at 27 °C and 125 atm springs a leak. When \n");
	printf("the leak was discovered, the pressure was reduced to 50 atm. How many moles \n");
	printf("of chlorine gas escaped?\n");
	printf("<a> 187.5 moles\n");
	printf("<b> 287.5 moles\n");
	printf("<c> 387.5 moles\n");
	printf("<d> 487.5 moles\n");
	printf("\nPlease key in your answer: ");
	scanf(" %c", &answer);

	if (answer == 'a')
	{score++;}

	//Calculate Total Marks

	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*          CHEMY's CHEMISTRY QUIZ... Your score will be...           *\n");
	printf("\t**********************************************************************\n");
	printf("\n\nYour score is %d/10.\n\n", score);
	printf("\n\nWould you like to go back to main menu? y/n\n");
	scanf(" %c", &back);
	if (back == 'y')
		{system ("cls");
		main ();}
	else if (back == 'Y')
		{system ("cls");
		main ();}
	else
		exit ();

}



//Calculator Menu

void calculator (void)
{
	
	int calculator;

	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*          Welcome to try CHEMY's CHEMISTRY CALCULATOR ^_^           *\n");
	printf("\t**********************************************************************\n\n\n");
	printf("\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
	printf("\t\t@     IDEAL GAS LAW CALCULATOR     @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@            MAIN MENU             @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@   1. PRESSURE                    @\n");
	printf("\t\t@   2. VOLUME                      @\n");
	printf("\t\t@   3. NUMBER OF MOL               @\n");
	printf("\t\t@   4. TEMPERATURE                 @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@   0. BACK                        @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n");
	printf("Please choose your menu: ");
	scanf("%d", &calculator);
	
	while (calculator != 0)
	{
	switch (calculator)
	{
		case 1 : pressure ();
			break;
		case 2 : volume ();
			break;
		case 3 : mol ();
			break;
		case 4 : temperature ();
			break;
		case 0 : printf("Goodbye");
			break;
		default :printf("I'm sorry, but you have enter an invalid selection. Please try again.\n\n");	
				 printf("Please choose your menu: ");
				 scanf("%d", &calculator);
			 break; 

	}
	}

	return;
}

//Calculator --- Pressure
void pressure (void)
{
	float volume;
	float mole;
	float temp;
	float pressure;
	char back;

	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*                    IDEAL GAS LAW < PRESSURE >                      *\n");
	printf("\t**********************************************************************\n\n\n");
	printf("Please key in the volume: ");
	scanf("%f", &volume);
	printf("\nPlease key in the number of mol: ");
	scanf("%f", &mole);
	printf("\nPlease key in the temperature: ");
	scanf("%f", &temp);
	pressure = (mole * 0.082057 * temp) / volume;
	printf("\n\nPressure --> %.4f\n\n", pressure);
	printf("\n\nWould you like to go back to main menu? y/n\n");
	scanf(" %c", &back);
	if (back == 'y')
		{system ("cls");
		main ();}
	else if (back == 'Y')
		{system ("cls");
		main ();}
	else 
		exit ();
}

//Calculator --- Volume
void volume (void)
{ 
	float volume;
	float mole;
	float temp;
	float pressure;
	char back;

	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*                    IDEAL GAS LAW < VOLUME >                        *\n");
	printf("\t**********************************************************************\n\n\n");
	printf("Please key in the pressure: ");
	scanf("%f", &pressure);
	printf("\nPlease key in the number of mol: ");
	scanf("%f", &mole);
	printf("\nPlease key in the temperature: ");
	scanf("%f", &temp);
	volume = (mole * 0.082057 * temp) / pressure;
	printf("\n\nVolume --> %.4f\n\n", volume);
	printf("\n\nWould you like to go back to main menu? y/n\n");
	scanf(" %c", &back);
	if (back == 'y')
		{system ("cls");
		main ();}
	else if (back == 'Y')
		{system ("cls");
		main ();}
	else 
		exit ();
}

//Calculator --- Number of Mol
void mol (void)
{ 
	float volume;
	float mole;
	float temp;
	float pressure;
	char back;

	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*                 IDEAL GAS LAW < NUMBER OF MOL >                    *\n");
	printf("\t**********************************************************************\n\n\n");
	printf("Please key in the pressure: ");
	scanf("%f", &pressure);
	printf("\nPlease key in the volume: ");
	scanf("%f", &volume);
	printf("\nPlease key in the temperature: ");
	scanf("%f", &temp);
	mole = ( pressure * volume ) / ( 0.082057 * temp );
	printf("\n\nNumber of mol --> %.4f\n\n", mole);
	printf("\n\nWould you like to go back to main menu? y/n\n");
	scanf(" %c", &back);
	if (back == 'y')
		{system ("cls");
		main ();}
	else if (back == 'Y')
		{system ("cls");
		main ();}
	else 
		exit ();
}

//Calculator --- Temperature
void temperature (void)
{ 
	float volume;
	float mole;
	float temp;
	float pressure;
	char back;

	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*                  IDEAL GAS LAW < TEMPERATURE >                     *\n");
	printf("\t**********************************************************************\n\n\n");
	printf("Please key in the pressure: ");
	scanf("%f", &pressure);
	printf("\nPlease key in the volume: ");
	scanf("%f", &volume);
	printf("\nPlease key in the number of mole: ");
	scanf("%f", &mole);
	temp = (pressure * volume) / (mole * 0.082057);
	printf("\n\nTemperature --> %.4f\n\n", temp);
	printf("\n\nWould you like to go back to main menu? y/n\n");
	scanf(" %c", &back);
	if (back == 'y')
		{system ("cls");
		main ();}
	else if (back == 'Y')
		{system ("cls");
		main ();}
	else 
		exit ();
}

//Optional Games
void optional (void)
{
	int games;

	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*          Welcome to try CHEMY's CHEMISTRY OPTIONAL GAMES!          *\n");
	printf("\t**********************************************************************\n\n\n");
	printf("\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
	printf("\t\t@     CHEMISTRY OPTIONAL GAMES     @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@            MAIN MENU             @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@   1. HANGMAN                     @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@   0. BACK                        @\n");
	printf("\t\t@                                  @\n");
	printf("\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n\n");
	printf("Please choose your menu: ");
	scanf("%d", &games);
	
	while (games != 0 ) 
	{
	switch (games)
	{
	case 1 : 
		hangman ();
		break;

	case 0 : 
		printf("Goodbye");
		break;

	default : 
		printf("I'm sorry, but you have enter an invalid selection. Please try again.\n\n");	
		printf("Please choose your menu: ");
		scanf("%d", &games);
		break;
	}
	}
			  

	return 0;
}


//Optional Games --- Hangman
void hangman (void)
{
	int wrong =0;
	int answer;
	char back;
	

	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*          Welcome to try Hangman optional games!                    *\n");
	printf("\t**********************************************************************\n\n\n");

	//Question 1
	printf("Answer as many question correctly as possible or the man will be hanged!!\n\n");
			
	 switch (wrong) 
	 {
     case 0 :
		printf("Amount of wrong answers: %d\n\n", wrong);
	    printf("\n");
	    printf("\n");
	    printf("\n");
	    printf("\n");
		printf("\n");
	    printf("\n");
		printf("____________\n\n");
        break;
	 }

   
	
	printf("Question 1\n");
	printf("What is the Atomic number of Potassium?\n");
	scanf("%d", &answer);

	if (answer != 19)
	{wrong++;}


	

	//Question 2
	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*          Welcome to try Hangman optional games!                    *\n");
	printf("\t**********************************************************************\n\n\n");


	printf("Answer as many question correctly as possible or the man will be hanged!!\n\n");
	switch (wrong) 
	{
     case 0 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("____________\n\n");
     break;


     case 1 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;
	 }

	printf("Question 2\n");
	printf("What is the Atomic number of Hydrogen?\n");
	scanf("%d", &answer);

	if (answer != 1)
	{wrong++;}


		
 	//Question 3
	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*          Welcome to try Hangman optional games!                    *\n");
	printf("\t**********************************************************************\n\n\n");


	printf("Answer as many question correctly as possible or the man will be hanged!!\n\n");
	 switch (wrong) 
	 {
     case 0 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("____________\n\n");
     break;

     case 1 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;

	case 2 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;
 }
	printf("Question 3\n");
	printf("What is the electron number of sodium?\n");
	scanf("%d", &answer);

	if (answer != 11)
	{wrong++;}

		
	
 	//Question 4
	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*          Welcome to try Hangman optional games!                    *\n");
	printf("\t**********************************************************************\n\n\n");


	printf("Answer as many question correctly as possible or the man will be hanged!!\n\n");
	 switch (wrong) 
	 {
     case 0 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("____________\n\n");
     break;

     case 1 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;

     case 2 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;

	 
     case 3 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |    |\n");
      printf("  |    |\n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;

	 }

	printf("Question 4\n");
	printf("What is the group number of silver?\n");
	scanf("%d", &answer);

	if (answer != 11)
	{wrong++;}


		
	
 	//Question 5
	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*          Welcome to try Hangman optional games!                    *\n");
	printf("\t**********************************************************************\n\n\n");


	printf("Answer as many question correctly as possible or the man will be hanged!!\n\n");
	switch (wrong) 
	{
     case 0 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("____________\n\n");
     break;


     case 1 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;

     case 2 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;

     case 3 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |    |\n");
      printf("  |    |\n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;

	 case 4 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|\n");
      printf("  |    | \n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;
	
	}

 
	printf("Question 5\n");
	printf("What is the neutron number of chlorine?\n");
	scanf("%d", &answer);

	if (answer != 18)
	{wrong++;}


		
	 
 	//Question 6
	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*          Welcome to try Hangman optional games!                    *\n");
	printf("\t**********************************************************************\n\n\n");


	printf("Answer as many question correctly as possible or the man will be hanged!!\n\n");
	switch (wrong) 
	{
     case 0 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("____________\n\n");
     break;

     case 1 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;

      case 2 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;

     case 3 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |    |\n");
      printf("  |    |\n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;

     case 4 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|\n");
      printf("  |    | \n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;
	
	 case 5 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|/\n");
      printf("  |    | \n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;
	}
 
	printf("Question 6\n");
	printf("What is the period number of sodium?\n");
	scanf("%d", &answer);

	if (answer != 3)
	{wrong++;}
	
		
	 
 	//Question 7
	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*          Welcome to try Hangman optional games!                    *\n");
	printf("\t**********************************************************************\n\n\n");


	printf("Answer as many question correctly as possible or the man will be hanged!!\n\n");
	switch (wrong) 
	{
     case 0 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("____________\n\n");
     break;

     
     case 1 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;

      case 2 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;

     case 3 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |    |\n");
      printf("  |    |\n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;

     case 4 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|\n");
      printf("  |    | \n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;

     case 5 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|/\n");
      printf("  |    | \n");
      printf("  |\n");
      printf("__|_________\n\n");
     break;

	 case 6 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|/\n");
      printf("  |    | \n");
      printf("  |   /\n");
      printf("__|_________\n\n");
	  break;
	}

	printf("Question 7\n");
	printf("What is the group number of oxygen?\n");
	scanf("%d", &answer);

	if (answer != 16)
	{wrong++;}

	 
	 
	 //Question 8
	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*          Welcome to try Hangman optional games!                    *\n");
	printf("\t**********************************************************************\n\n\n");


	printf("Answer as many question correctly as possible or the man will be hanged!!\n\n");
	switch (wrong) 
	{
     case 0 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("____________\n\n");
	  printf("Question 8\n");
	  printf("What is the proton number of Rubidium?\n");
	  scanf("%d", &answer);
 	if (answer != 37)
	{wrong++;}
	break;

	 case 1 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("__|_________\n\n");
      printf("Question 8\n");
	  printf("What is the proton number of Rubidium?\n");
	  scanf("%d", &answer);
	if (answer != 37)
	{wrong++;}
	break;

      case 2 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("__|_________\n\n");
      printf("Question 8\n");
	  printf("What is the proton number of Rubidium?\n");
	  scanf("%d", &answer);
 
	if (answer != 37)
	{wrong++;}
	break;

     case 3 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |    |\n");
      printf("  |    |\n");
      printf("  |\n");
      printf("__|_________\n\n");
      printf("Question 8\n");
	  printf("What is the proton number of Rubidium?\n");
	  scanf("%d", &answer);

	if (answer != 37)
	{wrong++;}
	break;

     case 4 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|\n");
      printf("  |    | \n");
      printf("  |\n");
      printf("__|_________\n\n");
    	 printf("Question 8\n");
	  printf("What is the proton number of Rubidium?\n");
	  scanf("%d", &answer);

	if (answer != 37)
	{wrong++;}
	break;

     case 5 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|/\n");
      printf("  |    | \n");
      printf("  |\n");
      printf("__|_________\n\n");
 	  printf("Question 8\n");
	  printf("What is the proton number of Rubidium?\n");
	  scanf("%d", &answer);

	if (answer != 37)
	{wrong++;}
	break;

     case 6 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|/\n");
      printf("  |    | \n");
      printf("  |   /\n");
      printf("__|_________\n\n");
	  printf("Question 8\n");
	  printf("What is the proton number of Rubidium?\n");
	  scanf("%d", &answer);
	  if (answer != 37)
	  {wrong++;}
	  break;

	 default :
		 break;

	}

	

	//Question 9
	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*          Welcome to try Hangman optional games!                    *\n");
	printf("\t**********************************************************************\n\n\n");


	printf("Answer as many question correctly as possible or the man will be hanged!!\n\n");
	
	 switch (wrong) {
     case 0 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("____________\n\n");
     
	 printf("Question 9\n");
     printf("What is the group number of calcium?\n");
	 scanf("%d", &answer);

	if (answer != 2)
	{wrong++;}
	break;

     case 1 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("__|_________\n\n");
      printf("Question 9\n");
      printf("What is the group number of calcium?\n");
	  scanf("%d", &answer);

	if (answer != 2)
	{wrong++;}
	break;

     case 2 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("__|_________\n\n");
      printf("Question 9\n");
	  printf("What is the group number of calcium?\n");
	  scanf("%d", &answer);

	if (answer != 2)
	{wrong++;}
	break;

     case 3 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |    |\n");
      printf("  |    |\n");
      printf("  |\n");
      printf("__|_________\n\n");
 	  printf("Question 9\n");
	  printf("What is the group number of calcium?\n");
	  scanf("%d", &answer);

	if (answer != 2)
	{wrong++;}
	break;

     case 4 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|\n");
      printf("  |    | \n");
      printf("  |\n");
      printf("__|_________\n\n");
	  printf("Question 9\n");
	  printf("What is the group number of calcium?\n");
	  scanf("%d", &answer);

	if (answer != 2)
	{wrong++;}
	break;

     case 5 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|/\n");
      printf("  |    | \n");
      printf("  |\n");
      printf("__|_________\n\n");
	  printf("Question 9\n");
	  printf("What is the group number of calcium?\n");
	  scanf("%d", &answer);

	if (answer != 2)
	{wrong++;}
	break;

     case 6 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|/\n");
      printf("  |    | \n");
      printf("  |   /\n");
      printf("__|_________\n\n");
	  printf("Question 9\n");
	  printf("What is the group number of calcium?\n");
	  scanf("%d", &answer);

	if (answer != 2)
	{wrong++;}
	break;
	 
	 default :
		 break;
	 
 }
	


	//Question 10
	system ("cls");
	printf("\t**********************************************************************\n");
	printf("\t*          Welcome to try Hangman optional games!                    *\n");
	printf("\t**********************************************************************\n\n\n");


	printf("Answer as many question correctly as possible or the man will be hanged!!\n\n");
	
	switch (wrong) {
     case 0 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("____________\n\n");
      printf("Question 10\n");
	  printf("What is the proton number of carbon?\n");
	  scanf("%d", &answer);

	 if (answer != 6)
	 {wrong++;}
	 break;


     case 1 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("__|_________\n\n");
	  printf("Question 10\n");
	  printf("What is the proton number of carbon?\n");
	  scanf("%d", &answer);
	
	if (answer != 6)
	{wrong++;}
	break;
   
     case 2 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("__|_________\n\n");
  	  printf("Question 10\n");
	  printf("What is the proton number of carbon?\n");
	  scanf("%d", &answer);

	if (answer != 6)
	{wrong++;}
	break;


     case 3 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |    |\n");
      printf("  |    |\n");
      printf("  |\n");
      printf("__|_________\n\n");
	  printf("Question 10\n");
	  printf("What is the proton number of carbon?\n");
	  scanf("%d", &answer);

	if (answer != 6)
	{wrong++;}
	break;


     case 4 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|\n");
      printf("  |    | \n");
      printf("  |\n");
      printf("__|_________\n\n");
	  printf("Question 10\n");
	  printf("What is the proton number of carbon?\n");
	  scanf("%d", &answer);

	if (answer != 6)
	{wrong++;}
	break;
	

     case 5 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|/\n");
      printf("  |    | \n");
      printf("  |\n");
      printf("__|_________\n\n");
 	  printf("Question 10\n");
	  printf("What is the proton number of carbon?\n");
	  scanf("%d", &answer);

	if (answer != 6)
	{wrong++;}
	break;
	
     case 6 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|/\n");
      printf("  |    | \n");
      printf("  |   /\n");
      printf("__|_________\n\n");
	  printf("Question 10\n");
	  printf("What is the proton number of carbon?\n");
	  scanf("%d", &answer);

	if (answer != 6)
	{wrong++;}
	break;
	
	 default:
		 break;

 }

	
	system("cls");
	printf("\t**********************************************************************\n");
	printf("\t*          Welcome to try Hangman optional games!                    *\n");
	printf("\t**********************************************************************\n\n\n");
	printf("Result:\n\n");
			switch (wrong) {
     case 0 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("\n");
      printf("____________\n\n");
	  printf("CONGRATULATIONS, THE MAN SURVIVE!");
     break;

      case 1 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("__|_________\n\n");
	  printf("CONGRATULATIONS, THE MAN SURVIVE!");
     break;

      case 2 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |\n");
      printf("  |\n");
      printf("  |\n");
      printf("__|_________\n\n");
	  printf("CONGRATULATIONS, THE MAN SURVIVE!");
     break;

     case 3 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |    |\n");
      printf("  |    |\n");
      printf("  |\n");
      printf("__|_________\n\n");
	  printf("CONGRATULATIONS, THE MAN SURVIVE!");
     break;

     case 4 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|\n");
      printf("  |    | \n");
      printf("  |\n");
      printf("__|_________\n\n");
	  printf("CONGRATULATIONS, THE MAN SURVIVE!");
     break;

     case 5 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|/\n");
      printf("  |    | \n");
      printf("  |\n");
      printf("__|_________\n\n");
	  printf("CONGRATULATIONS, THE MAN SURVIVE!");
     break;

     case 6 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|/\n");
      printf("  |    | \n");
      printf("  |   /\n");
      printf("__|_________\n\n");
	  printf("CONGRATULATIONS, THE MAN SURVIVE!");
     break;

     case 7 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|/\n");
      printf("  |    | \n");
      printf("  |   / \\\n");
      printf("__|_________\n\n");
	  printf("GMAE OVER");
     break;

	  case 8 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|/\n");
      printf("  |    | \n");
      printf("  |   / \\\n");
      printf("__|_________\n\n");
	  printf("GMAE OVER");
     break;

	 case 9 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|/\n");
      printf("  |    | \n");
      printf("  |   / \\\n");
      printf("__|_________\n\n");
	  printf("GMAE OVER");
     break;

 	 case 10 :
      printf("Amount of wrong answers: %d\n\n", wrong);
      printf("  _______\n");
      printf("  |/   | \n");
      printf("  |    O \n");
      printf("  |   \\|/\n");
      printf("  |    | \n");
      printf("  |   / \\\n");
      printf("__|_________\n\n");
	  printf("GMAE OVER");
     break;

	
}

	
	printf("\n\nWould you like to go back to main menu? y/n\n");
	scanf(" %c", &back);
	if (back == 'y')
		{system ("cls");
		main ();}
	else if (back == 'Y')
		{system ("cls");
		main ();}
	else
		exit ();
}

Also, initialize your menu variable(eg on line 45) to a value other than 4.

how about you initialize the value of menu to zero @ line 23

int menu = 0;

awesome,thanks both of you,but is there anyway to change it so that when a user input abc, the program wont crash?

Check out the Isdigit function.

k thanks alot

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.