C examples for Function:Recursive Function
This program performs summation of numbers 1 to 4 using recursion.
#include <stdio.h> int summation (int intM); int main(){//from w w w.j a v a 2s. c om int counter = 4, result; result = summation(counter); printf("Sum : 1 + 2 + 3 + 4 = %d\n", result); return(0); } int summation(int intM){ if (intM == 1) return 1; else return (intM + summation(intM - 1)); }