Guest User

Maths Quiz Problem

a guest
Nov 7th, 2013
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 7.79 KB | None | 0 0
  1. #include <stdio.h>
  2. main()
  3. {
  4.     int opt; //Menu options
  5.     int numof; //Number of questions
  6.     int ans; //Answers
  7.    
  8.     opt=0;
  9.    
  10.     numof=0;
  11.    
  12.     ans=0;
  13.    
  14.    
  15.  
  16.     printf("\n________________________________________________________________________________________________________");
  17.     printf("Select an option displayed below________________________");
  18.     printf("________________________________________________________________________________\n\n\n");
  19.     printf("1: Enter the number of questions to be asked for this round of the quiz (maximum of 5 questions allowed).\n\n");
  20.     printf("2: Start quiz\n\n");
  21.     printf("3: Display the number of questions that were answered (i) correctly and (ii) incorrectly for this round.\n\n");
  22.     printf("4: Exit Program\n");
  23.     printf("________________________________________________________________________________\n\n");
  24.    
  25.     scanf("%d", &opt);
  26.    
  27.    
  28.     if(opt==1)
  29.     {
  30.         if(numof==1)
  31.         {
  32.             printf("Let's begin\n");
  33.             printf("12x4=?\n");
  34.            
  35.             scanf("%d", &ans);
  36.            
  37.            
  38.             if(ans==48)
  39.             {
  40.                 printf("Success! You are correct");
  41.             }
  42.             else
  43.             {
  44.                 printf("Uh oh, you were wrong. Hard luck.");
  45.             }//End inner if 1
  46.         }//End middle if 1
  47.        
  48.        
  49.        
  50.        
  51.        
  52.         if(numof==2)
  53.         {
  54.             printf("Let's begin\n");
  55.             printf("12x4=?\n");
  56.            
  57.             scanf("%d", &ans);
  58.            
  59.             if(ans==48)
  60.             {
  61.                 printf("Success! You are correct\n\n");
  62.                 printf("102/2=?\n");
  63.                
  64.                 scanf("%d", &ans);
  65.                
  66.                
  67.                 if(ans==51)
  68.                 {
  69.                     printf("Success! You are correct\n");
  70.                 }
  71.                 else
  72.                 {
  73.                     printf("Uh oh, you were wrong. Hard luck.");
  74.                 }//End inner if 2b
  75.             }
  76.             else
  77.             {
  78.                 printf("Uh oh, you were wrong. Hard luck.");
  79.             }//End inner if 2a
  80.         }//End middle if 2
  81.        
  82.        
  83.        
  84.        
  85.        
  86.        
  87.         if(numof==3)
  88.         {
  89.             printf("Let's begin\n");
  90.             printf("12x4=?\n");
  91.            
  92.             scanf("%d", &ans);
  93.            
  94.             if(ans==48)
  95.             {
  96.                 printf("Success! You are correct\n\n");
  97.                 printf("102/2=?\n");
  98.                
  99.                 scanf("%d", &ans);
  100.                
  101.                
  102.                 if(ans==51)
  103.                 {
  104.                     printf("Success! You are correct\n\n");
  105.                     printf("10/2*3=?\n");
  106.                    
  107.                     scanf("%d", &ans);
  108.                    
  109.                    
  110.                     if(ans==15)
  111.                     {
  112.                         printf("Success! You are correct\n\n");
  113.                     }
  114.                     else
  115.                     {
  116.                         printf("Uh oh, you were wrong. Hard luck.");
  117.                     }//End innner if 3c
  118.                 }
  119.                 else
  120.                 {
  121.                     printf("Uh oh, you were wrong. Hard luck.");
  122.                 }//End inner if 3b
  123.             }
  124.             else
  125.             {
  126.                 printf("Uh oh, you were wrong. Hard luck.");
  127.             }//End inner if 3a
  128.         }//End middle if 3
  129.        
  130.        
  131.        
  132.        
  133.         if(numof==4)
  134.         {
  135.             printf("Let's begin\n");
  136.             printf("12x4=?\n");
  137.            
  138.             scanf("%d", &ans);
  139.            
  140.             if(ans==48)
  141.             {
  142.                 printf("Success! You are correct\n\n");
  143.                 printf("102/2=?\n");
  144.                
  145.                 scanf("%d", &ans);
  146.                
  147.                
  148.                 if(ans==51)
  149.                 {
  150.                     printf("Success! You are correct\n\n");
  151.                     printf("10/2*3=?\n");
  152.                    
  153.                     scanf("%d", &ans);
  154.                    
  155.                    
  156.                     if(ans==15)
  157.                     {
  158.                         printf("Success! You are correct\n\n");
  159.                         printf("40*2/4=?\n");
  160.                        
  161.                         scanf("%d", &ans);
  162.                        
  163.                        
  164.                         if(ans==20)
  165.                         {
  166.                             printf("Success! You are correct\n\n");
  167.                         }
  168.                         else
  169.                         {
  170.                             printf("Uh oh, you were wrong. Hard luck.");
  171.                         }//End inner if 4d
  172.                     }
  173.                     else
  174.                     {
  175.                         printf("Uh oh, you were wrong. Hard luck.");
  176.                     }//End innner if 4c
  177.                 }
  178.                 else
  179.                 {
  180.                     printf("Uh oh, you were wrong. Hard luck.");
  181.                 }//End inner if 4b
  182.             }
  183.             else
  184.             {
  185.                 printf("Uh oh, you were wrong. Hard luck.");
  186.             }//End inner if 4a
  187.         }//End middle if 4
  188.        
  189.        
  190.        
  191.        
  192.         if(numof==5)
  193.         {
  194.             printf("Let's begin\n");
  195.             printf("12x4=?\n");
  196.            
  197.             scanf("%d", &ans);
  198.            
  199.            
  200.             if(ans==48)
  201.             {
  202.                 printf("Success! You are correct\n\n");
  203.                 printf("102/2=?\n");
  204.                
  205.                 scanf("%d", &ans);
  206.                
  207.                
  208.                 if(ans==51)
  209.                 {
  210.                     printf("Success! You are correct\n\n");
  211.                     printf("10/2*3=?\n");
  212.                    
  213.                     scanf("%d", &ans);
  214.                    
  215.                    
  216.                     if(ans==15)
  217.                     {
  218.                         printf("Success! You are correct\n\n");
  219.                         printf("40*2/4=?\n");
  220.                        
  221.                         scanf("%d", &ans);
  222.                        
  223.                        
  224.                         if(ans==20)
  225.                         {
  226.                             printf("Success! You are correct\n\n");
  227.                             printf("75/3*5=?");
  228.                            
  229.                             scanf("%d", &ans);
  230.                            
  231.                            
  232.                             if(ans==125)
  233.                             {
  234.                                 printf("Success! You are correct\n\n");
  235.                             }
  236.                             else
  237.                             {
  238.                                 printf("Uh oh, you were wrong. Hard luck.\n\n");
  239.                             }//End inner 5e
  240.                         }
  241.                         else
  242.                         {
  243.                             printf("Uh oh, you were wrong. Hard luck.\n\n");
  244.                         }//End inner if 5d
  245.                     }
  246.                     else
  247.                     {
  248.                         printf("Uh oh, you were wrong. Hard luck.\n\n");
  249.                     }//End innner if 5c
  250.                 }
  251.                 else
  252.                 {
  253.                     printf("Uh oh, you were wrong. Hard luck.\n\n");
  254.                 }//End inner if 5b
  255.             }
  256.             else
  257.             {
  258.                 printf("Uh oh, you were wrong. Hard luck.\n\n");
  259.             }//End inner if 5a
  260.         }//End middle if 5
  261.        
  262.        
  263.     }//End main if
  264.    
  265.     flushall();
  266.     getchar();
  267.    
  268.    
  269. }//End main()
Advertisement
Add Comment
Please, Sign In to add comment