Yeah I just wanted to quickly make something confusing looking so that's what I got :)

Printable View

- 01-12-2010C_Sparky
- 01-12-2010dnilra
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;

}

- 01-12-2010dnilra
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;

}

- 01-12-2010Sebastiani
- 01-12-2010dnilra
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) - 01-12-2010Sebastiani
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. - 01-12-2010dnilra
Thanks all of you.

Finished. - 01-13-2010iMalc