C program Template
C program Template
No:5 ASSIGNMENT-5
29.09.2024
ROLLNO: 23IR016
AIM:
To create C programs that utilises the input/output library to read data from the keyboard and to
display data on the computer monitor.
1. Write a C program to calculate and print the factorials of the integers 0-20.
PROGRAM:
OUTPUT:
2. Write a C program to find the nth Fibonacci Number recursively.
PROGRAM:
OUTPUT:
3. Write a recursive function to generate all binary numbers of length n.
PROGRAM:
OUTPUT:
4. Write a recursive function to find the sum of digits of a given integer.
PROGRAM:
OUTPUT:
5. Write a recursive function to find GCD of n numbers.
PROGRAM:
OUTPUT:
6. Write a recursive function to count the occurrences of a specific digit in a
number.
PROGRAM:
OUTPUT:
PROGRAM:
OUTPUT:
8. Given a staircase with n steps, you can either take 1 step or 2 steps at a time.
Write a recursive function to count the number of ways to reach the top.
PROGRAM:
OUTPUT:
9. Write a C Program to convert Binary to Gray code using recursion.
PROGRAM:
OUTPUT:
10. Write a program to solve the Towers of Hanoi problem. Use a recursive
function with four parameters:
a) The number of disks to be moved.
b) The peg on which these disks are initially threaded.
c) The peg to which this stack of disks is to be moved.
d) The peg to be used as a temporary holding area.
PROGRAM:
OUTPUT:
RESULT:
The C programs that utilize the input/output library to read data from the keyboard and to
display data are successfully executed and the output is verified.