CPPForSchool.com: Flow of Control Set 2: Assignment 13

13. Write a program to calculate the sum of following series where n is input by user.
1 + 1/2 + 1/3 + 1/4 + 1/5 +…………1/n



This assignment was not too difficult.  However, when my source code is compared to the sample source solution, I once again took a different approach by comparison.  Unlike the use of int, float, and a for loop, my approach was to utilize double and a while loop.









Comments

Popular posts from this blog

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 9

CPPForSchool.com: Array - Single Dimension Set 1 Assignment 6

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 8