Building a Multiple Choice Quiz | Java | Tutorial 29



How to Write a Multiple Choice Program in C++

Steps

  1. Start Visual Studio Express and start a new project from the file menu.
  2. In the new project window choose select visual C++ on the right and choose win32 console application on the right.
    • In the wizard that shows up next check the box that says empty project.
  3. Add a new .cpp file by going into project and selecting add new item.
  4. Start the file by writing “#include <iostream>” and “using namespace std;” at the top of the file.
  5. Add a void function prototype for the end of the program that will take an integer for the number correct.
    • A function prototype will make a readily available function header which will be usable for underneath the programs main function, this is required for a void function to work.
    • Be sure to use a ‘&’ for the int variable, this will make the variable easier to move to each function.
  6. Add an int function prototype with two parameters, one for a character so that you can send the answer to the function and one for integers so that you can keep track of the amount that the user has right.
    • Again be sure to write a ‘&’ for the correct variable in the function.
  7. Write down the main function header for the programs main code.
    • This header starts with "int main()" with brackets underneath the code to where the code for the main function will be.
  8. Write the variables for the integer and character for use with the programs main function.
    • Be sure to add the integer variable correct to equal 0 so that the program can understand how to use the integer variable correctly.
  9. Write down what you want the answers for the quiz to be using “cout” functions.
    • For instance you can type a cout function saying the question's name..
    • You will also use these cout functions for each answer that the user can use.
  10. Write a “cin” line so that the user can type in their answers.
    • A "cin" function will let the user write down what the character for the choices in the multiple choice program.
  11. Write down a call for the answer function.
    • To call a function you write down the functions name as well as the parameters for example "functionname(answer)".
    • Be sure to write down the correct variables to put into the function so you do not switch them around.
  12. Start writing the new function for the question that the user has answered.
    • Be sure to use a switch structure that compares the answer character that the user wrote for there answer.
    • Use breaks in each case to not let the program keep going through the switch structure.
    • Also be sure to increment the number correct on correct answers so the program knows if the user got the question right.
  13. Return the number correct to the main program.
  14. Repeat the question adding process until you have the desired amount of questions for the quiz.
    • Be sure to add the new function prototype for the next question under the first questions function prototype, this will make it so you can write the next questions function right underneath the function for the last question.
  15. Start writing the function for the end of the program.
    • Be sure to add the end function in the main function so that you can send the program to the function.
    • Make the quiz display how many answers that the user has gotten correct, as well as writing down the percentage that the person has gotten right. Also make sure to use a double integer if you want to make the percentage have a decimal.
  16. Go back to the main function and add “return 0;” to end the program.
    • If you want to stop the program from exiting immediately type in “cin.ignore();” two times before the “return 0;” command so that you can exit the program by just hitting enter.
  17. Be sure to test the program to make sure it works.
    • If it does not work be sure to look for any errors in the code, Visual Studio Express will show incorrect code with a red square on the scroll line and also by underlining the incorrect code.





Video: How to Display a Multiple Choice Test on Microsoft Excel : Microsoft Excel Tips

How to Write a Multiple Choice Program in C
How to Write a Multiple Choice Program in C images

2019 year
2019 year - How to Write a Multiple Choice Program in C pictures

How to Write a Multiple Choice Program in C recommend
How to Write a Multiple Choice Program in C advise photo

How to Write a Multiple Choice Program in C picture
How to Write a Multiple Choice Program in C pics

How to Write a Multiple Choice Program in C How to Write a Multiple Choice Program in C new pictures
How to Write a Multiple Choice Program in C new pictures

pics How to Write a Multiple Choice Program in C
foto How to Write a Multiple Choice Program in C

Watch How to Write a Multiple Choice Program in C video
Watch How to Write a Multiple Choice Program in C video

Discussion on this topic: How to Write a Multiple Choice Program , how-to-write-a-multiple-choice-program/
Discussion on this topic: How to Write a Multiple Choice Program , how-to-write-a-multiple-choice-program/ , how-to-write-a-multiple-choice-program/

Related News


5 Easy and Healthy Kids Packed Lunches
Donald and Melania Trump: 3 inches (8 cm)
Osimertinib
Graham Allgood used Snapchat geofilter for internship interview
How to Meet Baba Ramdev
21 Last-Minute Gifts Guys Actually Want
Jalalabad in Afghanistan
Santa Rosa fire leads to worst air quality on record in San Francisco
The National, New York City
Top 12 things to do in Mumbai
How to Introduce a Puppy to a Dog
High protein diets could increase chances of heart attacks in women
This takeaway app lets you decide the exact calorie content of your order
8 Simple Ways to Stick to Your Statin Treatment
3 Simple Techniques To Darken Your Eyebrows



Date: 15.12.2018, 21:16 / Views: 41281