simple quiz program

Hello, I very recently started programming c++ with little programming knowledge.

I wrote this program in order to make a simple quiz.

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
#include <string>
#include <iostream>
#include <windows.h>

int question(std::string asked,std::string answer)
{
    int score;
    std::string input = "";
    using namespace std;
    cout << asked << endl;
    cin >> input;
    if (input == answer)
    {
        cout << "Correct!" << endl;
        score = 1;
    }
    else
    {
        cout << "Wrong!, It's " << answer << endl;
        score = 0;
    }
    return(score);
    Sleep(1000);
}

int main()
{
    using namespace std;
    int score;
    score = 0;
    cout << "Welcome to the easy capitals quiz 2.0! Please be aware that answers are case-sensitive." << endl;
    score = score + question("What's the capital of England?","London");
    cout << "Score:" << score << endl;
    Sleep(5000);
}


No matter if the answer's right or wrong, the score tells me a long number: 407288.

What did I do wrong?
Last edited on
Strangely it's the Sleep(1000); after your return... (which does nothing btw)

get rid of it, and it'll work.
Last edited on
I applied it, the score system works. Thanks
Of course, glad to help.
Topic archived. No new replies allowed.