# Thread: Question bout my work

1. ## Question bout my work

Code:
```    printf ("1.Enter the number of questions to be asked for this round of the quiz\n\n");      //Number of quizs
printf ("2.Start quiz\n\n");                                                                //Run questions
printf ("3.Display the number of questions answered (i) correct and (ii) incorrect\n\n");   //Display results
printf ("4.Exit Program\n\n");                                                              //Exit Program
printf ("Enter option : \n\n");
scanf  ("%d", &Selection);

if (Selection == 1)
{
printf ("How many  Question would you like to be asked? [ 1 - 4 ]\n");
scanf  ("%d\n", &SelectionQuestions);
}
else if (Selection == 2)
{
printf ("                           --------------------------\n");
printf ("                            -[-[ Question Begin ]-]- \n");
printf ("                           --------------------------\n\n");
printf ("----------------\n");
printf ("- 1st Question -\n");
printf ("----------------\n");
printf ("What is 1 + 1 = ?\n");
printf("\nYou got it right!!!\n\n\n");
else

printf ("----------------\n");
printf ("- 2nd Question -\n");
printf ("----------------\n");
printf("What is 10 - 5 = ?\n");
printf("\nYou got it right!!!\n\n\n");
else

printf ("----------------\n");
printf ("- 3rd Question -\n");
printf ("----------------\n");
printf("What is 3+4-10= ?\n");
printf("\nYou got it right!!!\n\n\n");
else
printf("\nIncorrect! The correct answer is -3\n\n\n");

printf ("----------------\n");
printf ("- 4th Question -\n");
printf ("----------------\n");
printf("What is 10+20+4-10 = ?\n");
printf("\nYou got it right!!!\n\n\n");
else
printf("\nIncorrect! The correct answer is 24\n\n\n");

}

system("PAUSE");
return 0;
}```
tis part of my assignment.
i cant figure the part where i select how many question to be asked that part.
can any1 just tutor me or show me any tutorial which is similar to it?

2. A few ideas:
- try to move the questions from the main to a function, and in main you could use a loop for the menu, and instead of if else, a switch might look nicer.

- you probably should ask first for the number of questions before showing the the menu, otherwise someone might start the quiz without specifying the number of questions.

- send the SelectionQuestions as a parameter to the function and then, depending on the value, call the appropriate number of questions.

3. Add some random numbers for the arithmetic to be done on.

4. You should also be checking the return value of scanf. It will return the number of items read, you should make sure it is reading in the same amount as variables you have after the format string.

5. What you need to do first of all is fix your indentation. It's impossible to see what belongs where.