Exercise 6 Programs on functions
Exercise 6 Programs on functions
DATE:
CO2: Comprehend the derived data types, pointers and creation of functions.
A. Aim :
Functions : Write a program to calculate factorial of a number using recursion.
B. Algorithm:
1. Start
2. For positive values of n, let's write n! as we did before, as a product of numbers starting
from n and going down to 1: n! = n.(n-1)….2.1
3. But notice that n! = n.(n-1)….2.1 is another way of writing (n-1)! , and so we can say
that n! = n.(n-1)….2.1.
4. Stop
C. C language Program
E. Learning Outcome:
F. Exercise-6:
6.1 Write a program to add, subtract, multiply and divide two integers using user-defined
type function with return type.
6.2 Write a program to calculate sum of first 20 natural numbers using recursive function.
6.3 Write a program to generate Fibonacci series using recursive function.
6.4 Write a program to swap two integers using call by value and call by reference methods
of passing arguments to a function.
6.5 Write a program to find sum of digits of the number using Recursive Function.
6.6 Write a program to read an integer number and print the reverse of that number using
recursion.
6.7 Write a C program to find maximum and minimum between two numbers using
functions.
6.8 Write a C program to check whether a number is even or odd using functions.
6.9 Write a C program to check whether a number is prime, Armstrong or perfect number
using functions.
6.10 Write a C program to find power of any number using recursion.
Pre Lab Marks (2-mark Max) In Lab Marks (3-mark Max) Post Lab Marks (5-mark Max)