1. Originally Posted by Sebastiani
Just FYI, gratuitous space != obfuscation.
Yeah I just wanted to quickly make something confusing looking so that's what I got

2. Originally Posted by Sebastiani
Alternately, you can use Gauss's equation: ( N * ( N + 1 ) ) / 2.
Heres what I did:
Code:
```#include <iostream>
//Write a program that calculates the sum N numbers.
using namespace std;
int main()
{
int N = 0;
int sum = 0;

cout << "Enter N...>"<< endl;
cin >> N;
for( int i = 1; i <= N; i = i + 1)
{
sum = sum + i;
}
cout << "The total sum of N numbers: " << sum << endl;
system ("pause");
return 0;
}```

3. OK take a look at this:
Write a program that calculates the sum of squares of numbers from 1 to N.

Heres what Ive done but the result (when i run) its not correct.
Code:
```#include <iostream>
//Write a program that calculates the sum of squares of numbers from 1 to N.
using namespace std;
int main()
{
int N = 0;
int sum = 0;

cout << "Enter a number...>" << endl;
cin >> N;

for( int i = 1; i <= N; i = i + 1){
sum = sum*sum + i;
}
cout << "The total sum of of squares of numbers from 1 to N is: " << sum << endl;
system ("pause");
return 0;
}```

4. Originally Posted by dnilra
OK take a look at this:
Write a program that calculates the sum of squares of numbers from 1 to N.

Heres what Ive done but the result (when i run) its not correct.
Code:
```#include <iostream>
//Write a program that calculates the sum of squares of numbers from 1 to N.
using namespace std;
int main()
{
int N = 0;
int sum = 0;

cout << "Enter a number...>" << endl;
cin >> N;

for( int i = 1; i <= N; i = i + 1){
sum = sum*sum + i;
}
cout << "The total sum of of squares of numbers from 1 to N is: " << sum << endl;
system ("pause");
return 0;
}```
Instead of multiplying the 'sum' with itself and then adding 'i', you should be adding the product of 'i' with itself to 'sum'.

Also, for future reference, you can simply use Aryabhata's formula: ( ( N * ( N + 1 ) * ( 2 * N + 1 ) ) / 6 ).

5. Originally Posted by Sebastiani
Instead of multiplying the 'sum' with itself and then adding 'i', you should be adding the product of 'i' with itself to 'sum'.

Also, for future reference, you can simply use Aryabhata's formula: ( ( N * ( N + 1 ) * ( 2 * N + 1 ) ) / 6 ).
Ok thanks I fixed that and its working . THanks a lot.

3 to go now:
Write a program to show all the numbers that are divisible by X from 1 to n (dont have a clue)
Write a program that calculates an average of n scores entered by user (dont understand it)
Write a program to create a countdown from N to 1 and display a text as a fire (need some serious help on this)

6. Originally Posted by dnilra
Ok thanks I fixed that and its working . THanks a lot.

3 to go now:
Write a program to show all the numbers that are divisible by X from 1 to n (dont have a clue)
Write a program that calculates an average of n scores entered by user (dont understand it)
Write a program to create a countdown from N to 1 and display a text as a fire (need some serious help on this)
1) Set up a loop as you did in your previous problems. Apply the modulo operator to the increment variable. If it's zero, then X divides it evenly, so print it.
2) Read input until the user is done. Each iteration, add it to the running total, and increment a counter that keeps track of the number of entries thus far (alternately, you can prompt the user for the number of scores to be entered, beforehand, but this is a bit less flexible). After the data entry phase is complete, divide the running total by the number of entries to obtain the average.
3) Not clear on the meaning of that one.

7. Thanks all of you.

Finished.

8. Originally Posted by dnilra
Im offering a domain in exchange for this...
Right, so you were publicly offering a bribe for others to help you break the rules?

Think again!