I'm trying to work through some exercises on for loops and I'm stuck on this one:
Write a program that takes two integers (one lower and one higher) and report the sum of all integers in between, including the two integers. For example, if 2 and 9 are entered the sum of all the integers is 44.
1 2 3 4 5 6 7 8 9 10
\\Getting the numbers - easy enough
cout << "Enter a number from 1 - 10: " << endl;
int small;
cin >> small;
cout << "\nEnter a number from 10 - 20: " << endl;
int big;
cin >> big;
So now I have these two numbers, and I'm not sure what the best way to do the rest is.
I tried doing this:
1 2 3 4
int sum = 0;
for (i = small; i == big; i++)
sum = sum + i;
but I got an error that said "i is not declared in this scope. If someone could point me in the right direction or get me a beer I would appreciate it.