Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
ClassQuiz
//g++ 7.4.0 ////////////////////////////////////////////////////////////////////////////// //ClassQuiz //quiz() code credit goes to thecleverprogrammer and SmallLion/Mr Unity Buddy of github //rest of the code created by Rezaul Hoque on May 23,2022; //contact:jewelmrh@yahoo.com;Dhaka,Bangladesh;https://rezaulhoque.wordpress.com,https://hoquestake.blogspot.com //note: codes shared by Rezaul Hoque on rextester are not for sale; they are created and shared to facilitate the algorithm learning process; many like Hoque use this platform to practice programming ;Rezaul hopes his contribution helps others to fine tune their learning; ////////////////////////////////////////////////////////////////////////////// #include <iostream> class Quiz{ public: void welcome (){ for (int k=0;k<35;k++){ std::cout<<">"; } std::cout<<"\n"; for(int k=0;k<35;k++){ std::cout<<"<"; } std::cout<<"\n"; std::cout<<"Welcome to the quiz!You have 3 questions.Each right answer will bring you 10."; } void multiCh(std::string x,std::string y,std::string z){ std::cout<<x<<","<<y<<","<<z<<"\n"; } void quiz(){ std::string RightAns[]={"Everest","Amazon","Bering"}; int score=0; std::string ans; std::cout<<"What is the name of the highest peak of the world?\n"; multiCh("Alps","Mt. Everest","Kilimanjaro"); std::cin>>ans; if (ans==RightAns[0]) { std::cout<<" Right you are!\n"; ++score;} else {std::cout<<"That's not right\n";} std::cout<<"Which one is the longest river on earth?\n"; multiCh("Ganges"," Mississippi "," Amazon"); std::cin>>ans; if(ans==RightAns[1]){ std::cout<<" Right you are!\n"; ++score; } else {std::cout<<"That's not right.\n";} std::cout<<"Which strait lies between USA and Russia?\n"; multiCh("Palk","Hormuz","Bering"); std::cin>>ans; if(ans==RightAns[2]) { std::cout<<" Right you are!\n"; ++score;} else {std::cout<<"That's not right.\n";} int m; m=score*10; std::cout<<"Your score is "<<m; if(m<30) std::cout<<". Try better next time!\n"; else if(m==30) std::cout<<". Awesome!\n"; } }; int main() { Quiz q; q.welcome(); q.quiz(); return 0; }
run
|
edit
|
history
|
help
0
Mine
segmentedSieveR
Click 5
PriQHotel2
const test
constructing object on first use as return value of (pointer to) object-returning function
Gauss v1.1
ThreadPool
List Add v3
Samosa