Advertisement
Guest User

Trivia.cpp

a guest
Apr 9th, 2020
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     string rightanswers[3] = {"A", "B", "C"};//array declaration
  6.     string user_input;
  7.     string questions[3]= {"What is my name. A) 10R B) Tanji C)Tanmoy", "which School do i go to A) Hunter B)QC C) BARUCH", "What CS class is this A)211 B) 311 C) 111"};//declaring array
  8.     int numRight=0;
  9.    
  10.     //char question[0] = { "What is my name.\n A) 10R \n B) Tanji \n C)Tanmoy \n" }//assigning questions to array
  11.     //char question[1] = { "which School do i go to \n A) Hunter \n B)QC \n C) BARUCH \n" }//assigning questions
  12.     //char question[2] = { "what CS class is this \n A)211 \n B) 311 \n C) 111 \n" }//assigning questions
  13.    
  14.     cout<<"For each question, type A, B, or C"<<endl;
  15.     for ( int i=0; i<3; i++)//for loop to show three questions
  16.     {
  17.         cout<<questions[i]<<endl;
  18.         cin >> user_input;
  19.         if(i==0){
  20.             if (user_input==rightanswers[0]);
  21.             numRight++;
  22.         }
  23.         if(i==1){
  24.             if(user_input==rightanswers[1]);
  25.             numRight++;
  26.         }
  27.         if(i==2){
  28.             if(user_input==rightanswers[2]);
  29.             numRight++;
  30.         }
  31.     }
  32.     cout<<"Percentage"<<"="<<numRight/3*100;
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement