Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- char *questions[10][5] = {
- { "What is the smallest unit in the computer system.", "Block", "Byte", "Bit", "C" },
- { "What is the most widely used device in the computer..", "Solid state disks", "Mouse", "Hard drive", "C" },
- { "WWW stands for.", "Wan Wide World.", "World Wide Web", "Wide Wan Web", "B" },
- { "What software is used to view web pages.", "Internet", "Web Browser", "Page Browser", "B" },
- { "Which one is a word processor.", "Notepad.", "Excel", "Word Perfect", "C" },
- { "How many bits are there in one byte.", "6", "8", "4", "B" },
- { "ISP stands for.", "International Service Provide", "Internet Service Printer", "Internet Service Provider", "C" },
- { "How many bytes are there in 2040 bits.", "255", "1024", "100", "A" },
- { "Every number system has a base, that is called", "Index", "Radix", "Subscript", "B" },
- { "A device that converts digital signals to analog signals is", "Packet", "Modem", "Block", "B" }
- };
- const int QUESTIONS = 10;
- int cur_question = 0;
- int Correct = 0;
- void ShowQuestion(int index){
- printf("%s\n\n",questions[index][0]);
- }
- void ShowAnswers(int qIndex){
- printf("%s\n\n",questions[qIndex][0]);
- printf("[A] %s\n",questions[qIndex][1]);
- printf("[B] %s\n",questions[qIndex][2]);
- printf("[C] %s\n",questions[qIndex][3]);
- printf("\nPlease enter a answer: ");
- }
- void CheckAnswer(int qIndex, char Answer){
- if(questions[qIndex][4][0] == Answer){
- Correct++;
- }
- }
- int main()
- {
- char Answer;
- while(cur_question < QUESTIONS){
- //Show question
- //Show answers
- ShowAnswers(cur_question);
- //Get answer
- scanf(" %c",&Answer);
- printf("\n");
- //Convert to uppercase
- Answer = toupper(Answer);
- //Check answer.
- CheckAnswer(cur_question,Answer);
- //INC counter
- cur_question++;
- //Add a small line break
- }
- if(Correct == 1)
- {
- printf("\nYou got %d answer correct\n",Correct);
- }else{
- printf("\nYou got %d answers correct\n",Correct);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement