Question
This is to be written in C programming. Please do not use arrays, pointers. This exercise focuses on iteration loops. 2 Exercise 1: Design harmonic_sequence
This is to be written in C programming. Please do not use arrays, pointers. This exercise focuses on iteration loops.
2 Exercise 1: Design harmonic_sequence function
Note: The harmonic sequence is
11,12,13,14,11,12,13,14,
or more generally, the ithith term in the sequence is the value 1i1i (with the first value corresponding to the case where i=1i=1).
TODO: Define and test the harmonic_sequence function that takes an integer n and prints the first n values of the harmonic sequence in the format below.
Note: The output below is for two calls to harmonic_sequence with values printed to 1010 decimal places. Make sure you print the same number of significant figures.
Note: Do not use a double variable to implement your loop counter (it is generally considered bad style to use floating point variables as loop counters).
harmonic_sequence called with a value of 7: i = 1: Sequence value is 1.0000000000 i = 2: Sequence value is 0.5000000000 i = 3: Sequence value is 0.3333333333 i = 4: Sequence value is 0.2500000000 i = 5: Sequence value is 0.2000000000 i = 6: Sequence value is 0.1666666667 i = 7: Sequence value is 0.1428571429 harmonic_sequence called with a value of 10: i = 1: Sequence value is 1.0000000000 i = 2: Sequence value is 0.5000000000 i = 3: Sequence value is 0.3333333333 i = 4: Sequence value is 0.2500000000 i = 5: Sequence value is 0.2000000000 i = 6: Sequence value is 0.1666666667 i = 7: Sequence value is 0.1428571429 i = 8: Sequence value is 0.1250000000 i = 9: Sequence value is 0.1111111111 i = 10: Sequence value is 0.1000000000
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started