solving exercises

Hello, I have to make program, but I’m a little (ok, totally) stuck.
Program has to make two random numbers (from 1 to 9) and a random function (+, -, *, /, %, ^). It have to make exercise (like 3+4=? Or 3^2) and ask user to enter answer. If answer is right, program has to say – “correct”, if not – “wrong”. Program has to make 10 exercises and rate user at the end. Like for 10 right answers – “10, you are good student’’ for 9 right answers – “9, try again”, for 8 answers – “8, try again” and so on.
I haven’t gotten past library adding and I totally have no idea, how to code this.

This is how far I've got:
1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include <cmath>
#include<cstdlib>   //needed to create random number
using namespace std;
int main()
{

    int x;
    int y;
    char operation;


Yes, I'm ashamed of myself.
Last edited on
Search google for "random number generator c++". There are tons of source code examples with comments and denotations about how to make a RNG. It's actually quite simple once you figure out exactly how the modulus behaves (the % sign) in an equation.
I know how to generate random number, but I have no idea about random exercise and random operation.
Just have it generate another random number, and based on that number, use a switch statement to determine the operation. Then have a variable that stores the value of that operation performed on the two numbers.
Topic archived. No new replies allowed.