square of odd #'s

ok, i have to output sum of the square of odd #'s between a num1 and num 2.
I have no idea where to start ='[
Just make a program that ask for two numbers, check to find the odd number in between and calculate the squares will you sum them up.

You ll probably have to try a little charder than this!
I would probably start with

1
2
3
4
int main()
{

}
1
2
3
4
5
6
7
8
9
10
#include <iostream>

int main() {
int n1, n2;
std::cin >> num1 >> num2;
int n1s = n1*(8*n1*n1-2)/6;
int n2s = n2*(8*n2*n2-2)/6;
std::cout << n2s-n1s;
return 0;
}
Topic archived. No new replies allowed.