Assignment PDS- OGI – Create a basic quiz in C language.

2
39576

Question :

Create a basic quiz based application in C, which should contain 20 questions from C language with following features :

1. The question type should be : MCQ, multiple answers and true/false

2. Each question should have negative marking for wrong answer

3. Final Score must be displayed at the end of the quiz.

Instructions :

This is just a basic template for the required program.

Things you need to do is : modify the messages accordingly, change the variable names, insert questions and options, and compile it too to eliminate possible syntax errors.

Code :

#include <stdio.h>

int main()

{

int marks;

int q1;

printf(“\nQuestion 1”);

printf(“\ write question 1 here”);

printf(“1. O1   2. O2    3. O3  4. O4 \n”);

printf(“Enter your answer\n”);

scanf(“%d”,&q1);

if(q1==(option number)

marks=marks+4;

else marks=marks-1;

 

int q2;

printf(“\nQuestion 2”);

printf(“\write question 2 here\n”);

printf(“1. O1   2. O2  3. O3   4. O4\nEnter your answer\n”);

scanf(“%d”,&q2);

if(q2== option number)

marks=marks+4;

else marks=marks-1;

 

int q3;

printf(“\nQuestion 3”);

printf(“\ question 3 here\n”);

printf(“1. O1   2. O2    3. O3  4. O4 \n”);

printf(“Enter your answer\n”);

scanf(“%d”,&q3);

if(q3== option number)

marks=marks+4;

else marks=marks-1;

 

int q4;

printf(“\nQuestion 4”);

printf(“\ question 4:\n”);

printf(“1.   2.    3.  4. \n”);

printf(“Enter your answer\n”);

scanf(“%d”,&q4);

if(q4== option number)

marks=marks+4;

else marks=marks-1;

 

int q5;

printf(“\nQuestion 5”);

printf(“\ question 5 :\n”);

printf(“1.   2.     3.  4 \n”);

printf(“Enter your answer\n”);

scanf(“%d”,&q5);

if(q5== option number

marks=marks+4;

else marks=marks-1;

 

int q6;

printf(“\nQuestion 6”);

printf(“\question 6 here? :\n”);

printf(“1.    2.     3.    4. \n”);

printf(“Enter your answer\n”);

scanf(“%d”,&q6);

if(q6== option number)

marks=marks+4;

else marks=marks-1;

 

int q7;

printf(“\nQuestion 7”);

printf(“\n question 7”);

printf(“1.    2.    3.    4.  \n”);

printf(“Enter your answer\n”);

scanf(“%d”,&q7);

if(q7== option number)

marks=marks+4;

else marks=marks-1;

 

int q8;

printf(“\nQuestion 8”);

printf(“\question 8 here \n”);

printf(“1.   2.   3.    4.  \n”);

printf(“Enter your answer\n”);

scanf(“%d”,&q8);

if(q8== option number)

marks=marks+4;

else marks=marks-1;

 

int q9;

printf(“\nQuestion 9”);

printf(“\n question 9”);

printf(“1.   2.   3.  4. \n”);

printf(“Enter your answer\n”);

scanf(“%d”,&q9);

if(q9== option number)

marks=marks+4;

else marks=marks-1;

 

int q10;

printf(“\nQuestion 10”);

printf(“\n question 10 here n”);

printf(“1.    2.    3.    4. \n”);

printf(“Enter your answer\n”);

scanf(“%d”,&q10);

if(q10== option number)

marks=marks+4;

else marks=marks-1;

//questions with 2 answers here

int s1, s2;

printf(“\nQuestion 11”);

printf(“\ question 11 here. \n”);

printf(“1.   2.   3.   4.  “);

printf(“Enter your answer\n”);

scanf(“%d%d”,&s1,&s2);

if((s1== option number || s1== option number) && (s2== option number || s2== option number))

marks=marks+4;

else marks=marks-1;

 

int s3, s4;

printf(“\nQuestion 12”);

printf(“\question 12n”);

printf(“1.    2.     3.    4.   “);

printf(“Enter your answer\n”);

scanf(“%d%d”,&s3,&s4);

if((s3== option number || s3== option number) && (s4== option number || s4== option number))

marks=marks+4;

else marks=marks-1;

 

int s5, s6;

printf(“\nQuestion 13”);

printf(“\question 13n”);

printf(“1.    2.      3.     4.   “);

printf(“Enter your answer\n”);

scanf(“%d%d”,&s5,&s6);

if((s5== option number || s5== option number) && (s6== option number || s6== option number))

marks=marks+4;

else marks=marks-1;

 

int s7, s8;

printf(“\nQuestion 14”);

printf(“\n question 14 heren”);

printf(“1.     2.      3.     4.  “);

printf(“Enter your answer\n”);

scanf(“%d%d”,&s7,&s8);

if((s7== option number || s7== option number) && (s8== option number || s8== option number))

marks=marks+4;

else marks=marks-1;

 

int s9, s10;

printf(“\nQuestion 15”);

printf(“\n question 15 here\n”);

printf(“1.      2.        3.      4.    “);

printf(“Enter your answer\n”);

scanf(“%d%d”,&s9,&s10);

if((s9== option number || s9== option number) && (s10== option number || s10== option number))

marks=marks+4;

else marks=marks-1;

 

char ch1[8];

//true false type

printf(“\nQuestion 16”);

printf(“\n question”);

printf(“True or False? \n”);

scanf(“%s”,ch1);

if(ch1==” true/false ” || ch1==” true/false”)

marks=marks+4;

else

marks=marks-1;

 

char ch2[8];

printf(“\nQuestion 17”);

printf(“\question 17\n”);

printf(“True or False? \n”);

scanf(“%s”,ch2);

if(ch2==” true/false ” || ch2==” true/false “)

marks=marks+4;

else

marks=marks-1;

 

char ch3[8];

printf(“\nQuestion 18”);

printf(“\question 18\n”);

printf(“True or False? \n “);

scanf(“%s”,ch3);

if(ch3==” true/false ” || ch3==” true/false “)

marks=marks+4;

else

marks=marks-1;

 

char ch4[8];

printf(“\nQuestion 19”);

printf(“\question 19n”);

printf(“True or False? \n”);

scanf(“%s”,ch4);

if(ch4==” true/false ” || ch4==” true/false “)

marks=marks+4;

else

marks=marks-1;

 

char ch5[8];

printf(“\nQuestion 20”);

printf(“\n question 20\n”);

printf(“True or False? “);

scanf(“%s”,ch5);

if(ch5==” true/false ” || ch5==” true/false “)

marks=marks+4;

else

marks=marks-1;

 

printf(“\n\nYour final marks out of 80 is :%d\n”,marks);

 

return 0;

}

 

 

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here