cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
new to program writing
new to program writing
Apr 3, 2012 at 6:50pm UTC
tate1
(7)
Write a program that uses a function to calculate the sum of all numbers from 1 to n then prints the result to the screen. The name of the function should be: sum. e.g. if n=5 then sum= 1+2+3+4+5
Apr 3, 2012 at 6:51pm UTC
vlad from moscow
(6539)
Here you are:)
inline int sum( int n ) { return ( n * ( n + 1 ) / 2 ); }
Topic archived. No new replies allowed.