c progam for mcq's

Discussion in 'C' started by neha chauhan, Nov 1, 2011.

  1. neha chauhan

    neha chauhan New Member

    Joined:
    Nov 1, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    cn anyone plsss tel me how to make a c program to check multiple choice questions (mcq's) with negative marking for wrong answer,,,,:confused::banghead::bigcry:
     
  2. ophelia.2010

    ophelia.2010 New Member

    Joined:
    Oct 18, 2011
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    student
    Location:
    london
    Code:
    #include<stdio.h>
    main()
    {
    int c,m,s=0;
    printf"("where does the sun rise?\n"); //your sample question
    printf("choices: 1.east 2.west 3. north 4.south ; Enter choice(1-4)\n");
    scanf("%d",&c);
    if(c==1)
    m=2;    // marks for correct answer
    else 
    m=-1;  // negative marking
    
    printf"("where does the sun set?\n"); //your sample question
    printf("choices: 1.east 2.west 3. north 4.south ; Enter choice(1-4)\n");
    scanf("%d",&c);
    if(c==2)
    m=2;  // marks for correct answer
    else 
    m=-1;  // negative marking
    s+=m;  // to store the final score of the user
    printf("Your score is :  %d",s);
    }
    
    You can include any number of questions like this!!! Hope this was useful!!!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice