Postby kate » Fri Jul 04, 2008 11:26 am

Make an algorithm which calculates the sum of n numbers using the cycle:
a) for{}
b) while{}
d0 while{}.
Posts: 91
Joined: Mon Apr 09, 2007 3:58 pm
Reputation: 2

Postby Fed_BG » Tue Aug 26, 2008 1:35 pm

Code: Select all

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.

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

Return to Programming and Algorithms

Who is online

Users browsing this forum: No registered users and 1 guest