Challenge: Keep Score

Lab C++ Beginner 10 points

Start an int variable score at 0. Add 10 to it, print it, then add 25 more and print it again. Use score = score + ... to update it.

Input

None.

Output

Score: 10
Score: 35

Example

Output

Score: 10
Score: 35
Sample output available
Editor
C++

Hints

Create the variable once with int, then just use its name.

score = score + 10; adds 10.

Solution explanation

The right side is worked out first using the old value, then the result is stored back in the same box.

Show solution
#include <iostream>
using namespace std;

int main() {
    int score = 0;
    score = score + 10;
    cout << "Score: " << score << "\n";
    score = score + 25;
    cout << "Score: " << score << "\n";
    return 0;
}
Output
Answer
HOME LABS COMMUNITY DASHBOARD