3 Replies - 518 Views - Last Post: 06 October 2012 - 08:34 AM Rate Topic: -----

#1 aakash2000  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-October 12

how to randomize the questions in quiz program

Posted 06 October 2012 - 02:54 AM

/* Programming in C FINAL PROJECT */
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>

    char Q1;
    char Q2;
    char Q3;
    char Q4;
    char Q5;
    char Q6;   
    char Q7;
    char Q8;
    char Q9;
    char Q10;
 
    int c,w;
 
    main()
 
{  
    printf ("1-What is 1 + 1?\nA=1\nB=2\nC=3\nD=4\n");
    scanf ("%c", &Q1);
        if ((Q1 == 'B')||(Q1 == 'b'))
        {c=c+1;
        printf ("\nCorrect Answer\n");
            }
        else
            {
        w=w+1;
        printf ("\nWrong Answer\n");
                 
            }
        printf ("2-What is 2 + 2?\nA=4\nB=2\nC=6\nD=8\n");
        scanf ("%s", &Q2);
        if ((Q2 == 'A')||(Q2 == 'a'))
     {
        c=c+1;
        printf ("\nCorrect Answer\n");
            }
        else
            {
        w=w+1;
        printf ("\nWrong Answer\n");
                 
            }
        printf ("3-What is 4 + 4?\nA=2\nB=6\nC=8\nD=9\n");
        scanf ("%s", &Q3);
            if ((Q3 == 'C')||(Q3 == 'c'))
            {c=c+1;
        printf ("\nCorrect Answer\n");
            }
        else
            {
        w=w+1;
        printf ("\nWrong Answer\n");
                 
                 }
        printf ("4-What is 4 + 7?\nA=2\nB=6\nC=2\nD=7\n");
        scanf ("%s", &Q4);
        if ((Q4 == 'D')||(Q4 == 'd'))
            {c=c+1;
        printf ("\nCorrect Answer\n");
            }
        else
            {
        w=w+1;
        printf ("\nWrong Answer\n");
                 
            }
        printf ("5-What is 1 + 3?\nA=2\nB=4\nC=3\nD=7\n");
        scanf ("%s", &Q5);
        if ((Q5 == 'B')||(Q5 == 'b'))
            {c=c+1;
        printf ("\nCorrect Answer\n");
            }
        else
            {
        w=w+1;
        printf ("\nWrong Answer\n");
                 
                 }
        printf ("6-What is 1 + 6?\nA=7\nB=6\nC=5\nD=10\n");
        scanf ("%s", &Q6);
        if ((Q6 == 'A')||(Q6 == 'a'))
            {   c=c+1;
        printf ("\nCorrect Answer\n");
            }
        else
            {
        w=w+1;
        printf ("\nWrong Answer\n");
                 
                 }
        printf ("7-What is 3 + 9?\nA=8\nB=18\nC=17\nD=12\n");
        scanf ("%s", &Q7);
        if ((Q7 == 'D')||(Q7 == 'd'))
            {c=c+1;
        printf ("\nCorrect Answer\n");
            }
        else
            {
        w=w+1;
        printf ("\nWrong Answer\n");
                 
            }
        printf ("8-What is 3 + 9?\nA=8\nB=18\nC=17\nD=12\n");
        scanf ("%s", &Q7);
        if ((Q7 == 'D')||(Q7 == 'd'))
            {   c=c+1;
        printf ("\nCorrect Answer\n");
            }
        else
            {
        w=w+1;
        printf ("\nWrong Answer\n");
                 
                 }
        printf ("7-What is 3 + 9?\nA=8\nB=18\nC=17\nD=12\n");
        scanf ("%s", &Q7);
        if ((Q7 == 'D')||(Q7 == 'd'))
            {c=c+1;
        printf ("\nCorrect Answer\n");
            }
        else
            {
        w=w+1;
        printf ("\nWrong Answer\n");
                 
            }
        printf ("7-What is 3 + 9?\nA=8\nB=18\nC=17\nD=12\n");
        scanf ("%s", &Q7);
            if ((Q7 == 'D')||(Q7 == 'd'))
            {   c=c+1;
            printf ("\nCorrect Answer\n");
            }
            else
            {
                w=w+1;
            printf ("\nWrong Answer\n");
                 
            }
            printf("\n\tTotal Score= %d\n",c);
 
 
getch ();
 
}


MOD EDIT: Added code tags. When posting code...USE CODE TAGS!!!

:code:

This post has been edited by JackOfAllTrades: 06 October 2012 - 03:12 AM


Is This A Good Question/Topic? 0
  • +

Replies To: how to randomize the questions in quiz program

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6066
  • View blog
  • Posts: 23,526
  • Joined: 23-August 08

Re: how to randomize the questions in quiz program

Posted 06 October 2012 - 03:13 AM

Let's start with this: Are you saying this is your final project, and yet you've not learned about arrays?
Was This Post Helpful? 2
  • +
  • -

#3 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3589
  • View blog
  • Posts: 11,161
  • Joined: 05-May 12

Re: how to randomize the questions in quiz program

Posted 06 October 2012 - 08:11 AM

Functions would also be useful. It's another topic that should have been covered.
Was This Post Helpful? 0
  • +
  • -

#4 jimblumberg  Icon User is offline

  • member icon


Reputation: 4098
  • View blog
  • Posts: 12,682
  • Joined: 25-December 09

Re: how to randomize the questions in quiz program

Posted 06 October 2012 - 08:34 AM

I would imagine that loops and possibly structures were also covered.

Jim
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1