Description
10 Points
This homework tests your understanding of the topics covered in the third week related to
C Programming – Functions.
1. Modify the program from Homework 2 to write a function, fib, that takes the
number of Fibonacci numbers as an input parameter and prints m Fibonacci
numbers where m is the input number of Fibonacci numbers that need to be
printed. Print each number. The main function should prompt and get the input and
make a call to the function to display the output. The formula for Fibonacci is fibn =
fibn-1+fibn-2.
Here’s a sample output:
Enter the number of Fibonacci numbers: 5
1: 1
2: 1
3: 2
4: 3
5: 5
2. An integer number is said to be a perfect number if its factors, including 1 (but not
the number itself), sum to the number. For example, 6 is a perfect number because 6
= 1 + 2 + 3. Write a function perfect that determines whether parameter number is
a perfect number and another function list_perfect that prints its factors. Use this
function in a program (main) that determines and prints all the perfect numbers
between 1 and 10000. Starter code is provided along with this homework. Add
perfect.c to your project and modify to get the following output.
Here’s a sample output:
Here are the perfect numbers between 1 and 10000
6 = 1 + 2 + 3
28 = 1 + 2 + 4 + 7 + 14
496 = 1 + 2 + 4 + 8 + 16 + 31 + 62 + 124 + 248
8128 = 1 + 2 + 4 + 8 + 16 + 32 + 64 + 127 + 254 + 508 + 1016 + 2032 + 4064
Challenge Work (2 Points): Write a function that takes an integer value and returns
the number with its digits reversed. For example, given the number 7631, the
function should return 1367.
Submission Instructions: Submit the code on Canvas under hw3 Submission link.
Submit the C source code files with the names fib.c and perfect.c (and reverse.c if
attempting extra credit).
Each program must contain a header in the following format.
/* Menaka Abraham
CES201
Autumn 2014
This program prints a simple Hello World to the console.
*/


