1 Replies - 389 Views - Last Post: 03 March 2012 - 03:25 PM Rate Topic: -----

#1 angelineang  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 03-March 12

how to set randomization and the highest score list in my quiz?

Posted 03 March 2012 - 02:56 PM

#include<stdlib.h>
#include<time.h>
#include<windows.h>

void quiz(void)

{

char answer[10]
char quizback,choice,score=0;

srand ( time(NULL) );
					for (int i=0;i<=10;i++);
					{
					question= rand () %20 + 1;
					printf("\n%d",i+1);
system("cls");
	  
		printf("\n\nThis is a CHEMISTRY QUIZ\n");
		printf("**********************\n\n");
		printf("Do you want to start now(Y/N) ");
	    scanf_s("%c",&choice);

		if(choice=='y')

		{


					//
					 system("cls");

                    printf("\n+++++++++++++++++++++++++++++++++\n");
					printf("+WELCOME TO CHEMISTRY QUIZ WORLD+\n");
					printf("+++++++++++++++++++++++++++++++++\n");
					
					printf("\t**********************************************************************\n");
					printf("\t* Welcome to CHEMY's CHEMISTRY QUIZ... Are you ready!Let's go! Wish you good luck??? *\n");
					printf("\t**********************************************************************\n");

					
					
					//Question1

					system("cls");

					printf("\tQ1. A gas occupies 40.0 mL at 127 oC. What volume will it occupy at -73 oC? (Assume pressure and number of particles is constant.)  ");
					printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A.182 mL\n B. 8.80 mL\n C.80.0 mL\n D.20.0 mL");


					scanf_s("%c",&answer);
						if(answer =='c')
						{
						printf("Nope.Remember that Charles Law is V1/T1=V2/T2");
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("Nope.Remember that Charles Law is V1/T1=V2/T2");
							}
							else

								if(answer =='c')							
								{
								printf("Nope.Remember that Charles Law is V1/T1=V2/T2");
								}
								else
							

										if(answer =='d')						
										{
										printf("CORRECT ");
										{score++;}
										}
										else

										{
											printf("Sorry,incorrect input");
										}





					//Question2
					system("cls");

					printf("\tQ2. A syringe contains 60.0 mL of air at 740 mm Hg pressure and 20 oC. What would be the temperature at which the syringe would contain 30.0 mL at a pressure of 370 mm Hg? (Assume no gas could leak in or out of the syringe. \n");
					printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A. -200 oC  \n B. 0.0137 oC \n C. 5 oC \n D. 73.3 oC");
					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("CORRECT");
						{score++;}
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("Nope.You made an algebra mistake and forgot to convert your answer back to degrees Celsius");
							}
							else

								if(answer =='c')							
								{
								printf("Nope.Do not use 20 degrees Celsius-remember to convert to Kelvins.");
								}
								else
							

										if(answer =='d')						
										{
										printf("Nope.Your answer is correct in Kelvins-subtract by 273 to convert to Celsius");
										}
										else

										{
											printf("Sorry,incorrect input");
										}



					//Question3
					system("cls");

					printf("\tQ3.The volume of a gas collected over water is 15.0 mL when the atmospheric pressure is 101.3 KPa. What will be the volume of the gas if the atmospheric pressure increases to 120.0 KPa. Assume that the vapor pressure of water is 2.7 KPa and that the temperature is constant. \n");
					printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A. 0.338mL  \n B. 12.3mL \n C. 12.6mL \n D. 12.9mL");
					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("Nope.You must subtract the vapour pressure of water from the atmospheric pressure");
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("\tNope.You must subtract the vapour pressure of water from the atmospheric pressure");
							}
							else

								if(answer =='c')							
								{
								printf("CORRECT");
								{score++;}
								}
								else
							

										if(answer =='d')						
										{
										printf("Nope.You must subtract the vapour pressure of water from the atmospheric pressure");
										}
										else

										{
											printf("Sorry,incorrect input");
										}


					//Question4
					system("cls");

					printf("\tQ4.A syringe contains 60.0 mL of air at 740 mm Hg pressure and 20 oC. What would be the temperature at which the syringe would contain 30.0 mL at a pressure of 370 mm Hg? (Assume no gas could leak in or out of the syringe. \n");
					printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A. -200oC  \n B. 0.0137oC \n C. 5oC \n D. 73.3oC");
					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("CORRECT");
						{score++;}
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("Nope.You made an algebra mistake and forhot to convert your answer back to degree Celcius.");
							}
							else

								if(answer =='c')							
								{
								printf("Nope.Do not use 20 degree Celcius-remeber to convert to Kelvins.");
								}
								else
							

										if(answer =='d')						
										{
										printf("Nope.Yor answer is correct in Kelvins-subtract by 273 to convert to Celcius.");
										}
										else

										{
											printf("Sorry,incorrect input");
										}



					//Question5
					system("cls");

					printf("\tQ5.What would happen if aqueous solutions of sodium nitrate and ammonium chloride were mixed?  \n");
					printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A. A precipitate of soidum chloride would form.  \n B. A precipitate of ammonium chloride would form. \n C.Precipitates of sodium chloride and ammonium chloride would form. \n D.No reaction.");
					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("Nope.Sodium Chloride is soluble");
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("Nope.Ammonium chloride is soluble.");
							}
							else

								if(answer =='c')							
								{
								printf("Nope.Neither would form");
								}
								else
							

										if(answer =='d')						
										{
										printf("CORRECT.");
									    {score++;}
										}
										else

										{
											printf("Sorry,incorrect input");
										}


					//Question6
					system("cls");

					printf("\tQ6.A compound is 40.0 % carbon, 53.3 % oxygen, and 6.66 % hydrogen. What is its empirical formula? \n");
					printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A. C4O5H7 \n B. C1O2H3 \n C.C1O1H2l \n D.More than one could be the correct empirical formula.");
					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("Nope.You must divide the percent by the molar mass and then look for the smallest whole number ratio.");
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("Nope.You might hae forgotten the molar mass for carbon and oxygen reversed");
							}
							else

								if(answer =='c')							
								{
								printf("CORRECT");
								{score++;}
								}
								else
							

										if(answer =='d')						
										{
										printf("Nope");
										}
										else

										{
											printf("Sorry,incorrect input");
										}


					//Question7
					system("cls");

					printf("\tQ7.A container of negligible mass is filled first with argon and then with helium. Which statement below would be true about the masses of the two gases (after adjustment for the buoyant effect of air?  \n");
						printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A. The mass of the helium would be 1/9th that of argon. \n B. C1O2H3The mass of the helium would be 1/10th that of argon. \n C.The mass of helium would be 9x that of argon. \n D.The mass of helium would be 10x that of argon.");
					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("Nope.You are confusing atomic numbers and aromic masses.");
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("CORRECT");
							{score++;}
							}
							else

								if(answer =='c')							
								{
								printf("Nope.Helium is lighter than carbon");
								}
								else
							

										if(answer =='d')						
										{
										printf("Nope.Helium is lighter than carbon");
										}
										else

										{
											printf("Sorry,incorrect input");
										}


					//Question8
					system("cls");

					printf("\tQ8.\t\t\tCH4 (g) + 2 O2 (g) CO2 (g) + 2 H2O (g) + 810 KJ  \n");
					printf("In the reaction above, 3 moles of CH4 could produce how many moles of H2O? ");
					printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A. 1/2 mol H2O \n B. 2mol H2O \n C.6mol H2O \n D.5 mol H2O");
				
					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("Nope.");
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("Nope");
							}
							else

								if(answer =='c')							
								{
								printf("CORRECT");
								{score++;}
								}
								else
							

										if(answer =='d')						
										{
										printf("Nope.");
										}
										else

										{
											printf("Sorry,incorrect input");
										}


				//Question9
					system("cls");

					printf("\tQ9.A 4.0 L sample of hydrogen gas at 700 mm Hg would occupy what volume at 250 mm Hg? (Assume temperature and number of particles stays constant.  \n");
					printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A. 1.4 x 10^-7 L \n B. 1.4L \n C.11.2L \n D.2.4L");
					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("Nope.Remember that P1 x V1=P2 x V2");
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("Nope.Remember that P1 x V1=P2 x V2");
							}
							else

								if(answer =='c')							
								{
								printf("CORRECT");
								{score++;}
								}
								else
							

										if(answer =='d')						
										{
										printf("Nope.Remember that P1 x V1=P2 x V2");
										}
										else

										{
											printf("Sorry,incorrect input");
										}


					//Question10
					system("cls");

					printf("\tQ10.How many moles are there in 2.4 x 10 24 atoms of He?  \n");
					printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A. 2.4 x 10^24 mol \n B.4.0 mol \n C.2.0 mol \n D.6.0 mol");
					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("Nope.Remember that there are 6.02E 23 atoms in one mole");
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("CORRECT");
							{score++;}
							}
							else

								if(answer =='c')							
								{
								printf("Nope.Remember that there are 6.02E 23 atoms in one mole");
								}
								else
							

										if(answer =='d')						
										{
										printf("Nope.Remember that there are 6.02E 23 atoms in one mole");
										}
										else

										{
											printf("Sorry,incorrect input");
										}


					//Question11
					system("cls");

					printf("\tQ11.A compound contains 6.0 g of cabon and 1.0 g of hydrogen. The percent composition of the compound is:   \n");
					printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A. 14 % hydrogen and 86 % carbon \n B.86 % hydrogen and 14 % carbon \n C.17 % hydrogen and 83 % carbon \n D.83 % hydrogen and 17 % carbon");
					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("CORRECT");
						{score++;}
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("Nope.Your percents are backwards");
							}
							else

								if(answer =='c')							
								{
								printf("Nope.The compound has a total mass of 7.0g,not 6.0g");
								}
								else
							

										if(answer =='d')						
										{
										printf("Nope.Your percents are backwards and the total mass of the compound is 7.0g");
										}
										else

										{
											printf("Sorry,incorrect input");
										}

					//Question12
					system("cls");

					printf("\tQ12.Which of the following substances would likely dissolve in water: \n");
					printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A. Zn(NO3)2 \n B.AgCl\n C.NaOH \n D.More than one of above would be dissolve in water.\n");


					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("This is correct,but not the only one answer");
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("Nope.");
							}
							else

								if(answer =='c')							
								{
								printf("This is correct,but not the only one answer");
								}
								else
							

										if(answer =='d')						
										{
										printf("CORRECT");
										{score++;}
										}
										else

										{
											printf("Sorry,incorrect input");
										}

					//Question13
					system("cls");

					printf("\tQ13.A 63.0 g piece of aluminum (Specific Heat = 0.215 cal / (g oC) ) at 25.0 oC is warmed by the addition of 325 calories of energy. Find the final tempearture of the aluminum \n");
					printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A. 49.0oC \n B.240oC \n C.26.1 oC\n D.1.11oC\n");


					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("CORRECT");
						{score++;}
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("Nope.Remember you started at 25 degree Celcius");
							}
							else

								if(answer =='c')							
								{
								printf("Nope.Set up the problem so that units cancel correctly");
								}
								else
							

										if(answer =='d')						
										{
										printf("Nope.Set up the problem so that units cancel correctly and add 25 degree Celcius to your answer");
										}
										else

										{
											printf("Sorry,incorrect input");
										}

					//Question14
					system("cls");

					printf("\tQ14.If 4 moles of a gas are added to a continer that already holds 1 mole of gas, how will the pressure change within the container? (Assume volume and temperature are constant.) \n");
					printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A. 49.0 oC \n B.240oC \n C.26.1 oC\n D.1.11oC\n");


					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("CORRECT");
						{score++;}
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("Nope.");
							}
							else

								if(answer =='c')							
								{
								printf("Nope.1+4=5,therefore the pressure will be 5x as great");
								}
								else
							

										if(answer =='d')						
										{
										printf("Nope.");
										}
										else

										{
											printf("Sorry,incorrect input");
										}

					//Question15
					system("cls");

					printf("\tQ15. A sealed container contains 1.0 mol of hydrogen and 2.0 moles of nitrogen gas. If the total pressure in the container is 1.5 atm, what is the amount of pressure exerted by each gas? \n");
					printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A.H2 = 1.0 atm and N2 = .50 atm \n B.H2 = 0.50 atm and N2 = 1.0 atm \n C.H2 = 1.0 atm and N2 = 2.0 atm \n D.H2 = 2.0 atm and N2 = 1.0 atm\n");


					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("Nope.There are not as many mplecules of hydrogen,so they will not contribute to most of the pressure.");
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("CORRECT.");
							{score++;}
							}
							else

								if(answer =='c')							
								{
								printf("Nope.he total pressure is not 3.0atm");
								}
								else
							

										if(answer =='d')						
										{
										printf("Nope.he total pressure is not 3.0atm");
										}
										else

										{
											printf("Sorry,incorrect input");
										}

					//Question16
					system("cls");

					printf("\tQ16.  A sample of gas is collected by water displacement. The atmospheric pressure in the room is 757 mm Hg and the vapor pressure of water is 17 mm Hg. What is the partial pressure of hydrogen under these conditions?  \n");
					printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A.17 mm Hg \n B.740 mm Hg \n C.757 mm Hg \n D.H2 =774 mm Hg\n");


					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("Nope.This is the pressure exerted as water molecules evaporate into the gas container");
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("CORRECT! P total= P water + P hydrogen");
							{score++;}
							}
							else

								if(answer =='c')							
								{
								printf("Nope.The total pressure--757 mmHg is equal to the pressure of wate plus the pressure of the hydrogen,You need to do a subtraction");
								}
								else
							

										if(answer =='d')						
										{
										printf("Nope.P total= P water + P hydrogen");
										}
										else

										{
											printf("Sorry,incorrect input");
										}

					//Question17
					system("cls");

					printf("\tQ17. 15 g of NaCl occupy a volume of 75 mL. What is the molarity of the solution?   \n");
					printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A.3.4M \n B.0.29 M \n C.0.019M \n D.0.0034M\n");


					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("CORRECT");
						{score++;}
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("Nope.Molarity is moles per liter ,not liters per mole.");
							}
							else

								if(answer =='c')							
								{
								printf("Nope.Make sure that your units cancel to give moles per liter.");
								}
								else
							

										if(answer =='d')						
										{
										printf("Nope.Use liters,not mililiters");
										}
										else

										{
											printf("Sorry,incorrect input");
										}

					//Question18
					system("cls");

					printf("\tQ18. In the reaction given in problem 5, 80.0 mL of 2.0 M HCl would react with how many grams of aluminum? \n");
					printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A.1.44g \n B.4.32g \n C.1440g \n D.2030g\n");


					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("CORRECT");
						{score++;}
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("Nope.Do not forget to use mole ratio.");
							}
							else

								if(answer =='c')							
								{
								printf("Nope.Did you forget to change milliliters to liters.");
								}
								else
							

										if(answer =='d')						
										{
										printf("Nope.Cancel your units properly");
										}
										else

										{
											printf("Sorry,incorrect input");
										}
					//Question18
					system("cls");

					printf("\tQ18.When a hydrocarbon undergoes complete combustion the products are: \n");
					printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A.carbon dioxide and water \n B.carbon dioxide and hydrogen \n C.carbon dioxide and oxygen \n D.carbon and hydrogen\n");


					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("CORRECT");
						{score++;}
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("Nope.");
							}
							else

								if(answer =='c')							
								{
								printf("Nope.");
								}
								else
							

										if(answer =='d')						
										{
										printf("Nope.");
										}
										else

										{
											printf("Sorry,incorrect input");
										}
					//Question19
					system("cls");

					printf("\tQ19.In the reaction above, the production 5.0 x 10 24 molecules of H2O would result in how many moles of CO2?  \n");
				    printf("\nPlease key in your answer:(a/b/c/d ");
					printf("A.0.060 mol CO2 \n B.0.24 mol CO2 \n C.4.2 mol CO2 \n D.16.6 mol CO2\n");


					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("CORRECT");
						{score++;}
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("Nope.");
							}
							else

								if(answer =='c')							
								{
								printf("CORRECT");
								{score++;}
								}
								else
							

										if(answer =='d')						
										{
										printf("Nope.");
										}
										else

										{
											printf("Sorry,incorrect input");
										}

					//Question20
					system("cls");

					printf("\tQ20.In the reaction above, the production 5.0 x 10 24 molecules of H2O would result in how many moles of CO2?  \n");
					printf("\nPlease key in your answer:(a/b/c/d ");
			
					printf("A.0.56 g / L \n B.1.78 g / L \n C.22.4 g / L \n D.40. g / L\n");


					scanf_s("%c",&answer);

					if(answer =='a')
						{
						printf("Nope.Your units do not cancel to give out g/L.");
						}
						else
		
							
							if(answer =='b')					
							{				
							printf("CORRECT.");
							{score++;}
							}
							else

							if(answer =='c')							
								{
								printf("This is the number of liters in a mole at STP");
								}
								else
							

										if(answer =='d')						
										{
										printf("This is molar mass of argon.");
										}
										else

										{
											printf("Sorry,incorrect input");
										}
		}

printf("\t******************************************************************************\n");
printf("\t*       Thanks for your answering  Your final score are %d/10  \n\n          *",score);
printf("\t******************************************************************************\n");

printf("\n\nAre you want to back to main menu(y) or redo(n)? \n");
scanf_s(" %c", &quizback);
if ( quizback == 'y')
{
system("cls");
main ();
}




	else
	if(quizback =='n')
	{
	quiz();
	}
}
			else
			if(choice=='n')

			{
				return main();
			}


Is This A Good Question/Topic? 0
  • +

Replies To: how to set randomization and the highest score list in my quiz?

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6245
  • View blog
  • Posts: 24,013
  • Joined: 23-August 08

Re: how to set randomization and the highest score list in my quiz?

Posted 03 March 2012 - 03:25 PM

Don't create new topics when you already have one on the same program.

Closed.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1