# Algorithm

### Algorithm

Make an algorithm which calculates the sum of n numbers using the cycle:
a) for{}
b) while{}
d0 while{}.
kate

Posts: 91
Joined: Mon Apr 09, 2007 3:58 pm
Reputation: 2

Code: Select all
C++:int sum = 0;for (int i = 1; i <= n; ++i)     sum += i;

I hope someone else will try the others.
Let me generalize the algorithm. Try to do it in as many languages as you can.

Fed_BG

Posts: 17
Joined: Sun Jul 15, 2007 1:22 pm
Location: Bulgaria
Reputation: 0