It looks inconsistent with too few spaces per indent.
However, it also looks like you have been trying though, so here is an example of your code in well indented form:
Aside from fixing indentation and spacing, I took the liberty of removing an unused variable (do not declare what you do not use), changing the scope of i, random_integer1 and random_integer2 (declare variables near first use), and also changing the C-style type casts to C++ style static_cast (more descriptive and easier to find).Code:#include <iostream> #include <ctime> #include <cstdlib> using namespace std; int main() { srand((unsigned)time(0)); int answer; int realanswer; int lowest = 0, highest = 49; int range = (highest - lowest) + 1; for (int j = 0; j < 10; ++j) { int random_integer1 = lowest + static_cast<int>(range * rand() / (RAND_MAX + 1.0)); int random_integer2 = lowest + static_cast<int>(range * rand() / (RAND_MAX + 1.0)); cout << "If I add " << random_integer1 << " and " << random_integer2 << " then what do I have? " << endl; cin >> answer; realanswer = random_integer1 + random_integer2; } for (int j = 0; j < 10; ++j) { for (int i = 0; i < 2; ++i) { if (answer == realanswer) { cout << "You are Right" << "\n"; break; } else { if (i == 1) { cout << "You are wrong. The right answer is " << realanswer << "\n"; } else { cout << "Oops! You are wrong. Try again...\n"; cin >> answer; } } } } }
Note however that the casting of time(0) to unsigned int is not guaranteed to work (though it probably will). Read Prelude's article on using rand() for a portable alternative, namely hashing the bytes returned by time(0).