-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask2.cpp
More file actions
43 lines (35 loc) · 970 Bytes
/
Task2.cpp
File metadata and controls
43 lines (35 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include <vector>
#include <string>
using namespace std;
struct Quiz
{
string Question;
vector<string> Options;
int Correctans;
};
int main()
{
vector<Quiz> quiz = {
{"What is 2 + 2?", {"1", "2", "4", "5"}, 2},
{"Capital of India?", {"Mumbai", "Delhi", "Chennai", "Kolkata"}, 1},
{"C++ is a ___ language?", {"Markup", "Programming", "Scripting", "Design"}, 1}
};
int correct = 0,answer;
for(int i=0;i<quiz.size();i++){
cout<<"\nQ"<<i+1<<" : "<<quiz[i].Question<<endl;
for(int j=0;j<quiz[i].Options.size();j++){
cout<<j+1<<". "<<quiz[i].Options[j]<<endl;
}
cout<<"Answer the Correct Answer : ";
cin>>answer;
if(quiz[i].Correctans==answer-1){
correct++;
cout<<"Correct"<<endl;
}else{
cout<<"Wrong"<<endl;
}
}
cout<<"Total Correct Answer : "<<correct<<endl;
return 0;
}