Starting from:

$25

CSE102 - Computer Programming  - Homework #3  - Solved

You will write a C file with the main function with additional functions described below. Your Program will start calling part1 and part 2 in that order. For each part, you will receive the inputs from the user and print the output to the console. Details of the parts are further discussed below. Please pay attention to the output format. Any deviation from the shared format may be penalized regardless of the correct execution.

Part 1. [25pts] Your function will read one integer from the command prompt as term number of Fibonacci Sequence. If the input number is not positive integer value then your program will print the message explaining the reason for ineligibility. Your function will continue until it gets the correct input. Print the Fibonacci Sequence elements as many as the number of input. Let the function continue working until it gets the ‘*’ input then move on to the other part.

Example 1:

            Please enter term(s) number : -5

            Please enter “positive” term(s) number: a

            Please enter “numeric” term(s) number:7

            Fibonacci Sequence:

            1

            1

            2

            3

            5

            8

            13

Function prototype is void calculate_fibonacci_sequence()

Part 2. [30pts] Your function will read one integer from the command prompt. Your second function will decide whether the entered number is Perfect Number and Harmonic Divisor Number. The input must be a natural number. Perfect Number is the number at which the sum of all natural number divisor of a natural number n is equal to itself.(1 included, not including itself). Harmonic Divisor Number or Ore Number is a positive integer whose divisors have a harmonic mean that is an integer. Let the function continue working until it gets the ‘*’ input then end the program.

Example 2.

            Please enter input number : 6

            Natural Number Divisors: 1 , 2 , 3, 6  

            Is Perfect Number? : Yes  

            Hint: 1+2+3 = 6 and input 6. That’s why it’s the perfect number.

            Is Harmonic Divisor Number? : Yes

            Hint: Number 6 has the four divisors. Their harmonic mean is an integer:

            4 / ((1/1) + (1/2) + (1/3) + (1/6)) = 2  

Please enter input number : 28

Natural Number Divisors: 1, 2, 4 , 7, 14, 28

Is Perfect Number? : Yes

Hint: 1 + 2 + 4 + 7 + 14 = 28 and input 28. That’s why it’s the perfect number.

Is Harmonic Divisor Number? : Yes

Hint: Number 28 has the six divisors. Their harmonic mean is an integer:

6 / ((1/1) + (1/2) + (1/4) + (1/7) + (1/14) + (1/28) = 2

Please enter input number : 15

            Natural Number Divisors: 1, 3, 5, 15

            Hint: 1 + 3 + 5 = 9 but input 15. That’s why it’s not the perfect number.

            Is Perfect Number? : No

Is Harmonic Divisor Number? : No

Hint: Number 15 has the four divisors. Their harmonic mean is not an integer:

4 / ((1/1) + (1/3) + (1/5) + (1/15)) = 1.6

Function prototype is void decide_perfect_harmonic_number()

Part 3. [20pts] Your function will enter 5 integer or double numbers from the command prompt then find the maximum and minimum numbers.  Your function will calculate diffarence between minimum and maximum.

Example 3.

            Please enter 5 numbers: 2 8 180 74 -8.8

            Hint: Maximum number is 180, minimum number is -8.8

            Maximum number is: 180  

            Minimum number is: -8.8

            Difference between maximum and minimum is 188.8

            Hint: Difference mean is maximum – minimum, not minimum – maximum

Function prototype is void difference_max_min ()

Part 4. [25pts] Your function will enter weight and height then calculate BMI(Body Mass Index). Your function will return which category the person belongs to.  

Hint: BMI = weight(kg) / ℎ𝑒𝑖𝑔ℎ𝑡2(𝑚) Function prototype is void bmi_calculation () Hint:  

BMI 
Category 
< 16.0  
Severely Underweight
16.0 – 18.4
Underweight
18.5 – 24.9
Normal
25.0 – 29.9  
Owerweight
> 30.0
Obese
 

Example 4.  

            Please enter weight(kg) : 65

            Please enter height(m): 1.68

            Your category: Normal

            Hint: BMI = 65 / (1.68)2 = 23.03, within the normal category.


 

  

More products