I'm extremely new to c++.
I've been reading the tutorials and decided to write my own little program
I want the program to ask a couple of questions, and based on your answers, output your score as a percentage.
I was able to write part of it, but I don't know how to complete it.
I can't figure out how to get the program to see how many you got right, then calculate your score.
Such as, if I got two right, I want it to say "your score is 66%" Or if I just got one right, "your score is 33%"
How would I go about doing this?
Heres the code I have so far.
Code:#include<iostream> using namespace std; int main () { int add; int sub; int div; cout << "Whats 2 + 2? "; cin >> add; cout << "Whats 2 - 2? "; cin >> sub; cout << "Whats 20 / 4? "; cin >> div; if (add == 4 && sub == 0 && div == 5) { cout << "Your score is 100%! \n "; } else { cout << "You got one wrong :( \n"; } system("Pause"); return 0; }



LinkBack URL
About LinkBacks



