Tuesday 9 June 2009

Why we should use the function?

1. Function reduces the redundancy of code. Example: 1 Write a c program to find the sum of: 1! /5+ 2! /4+ 3! /3+ 4! /2+ 5! /1 without using function (Except main function). Where! Symbol indicates factorial of any number. void main(){ int num, sum=0; int fact1,fact2,fact3,fact4,fact5; fact1=fact2=fact3=fact4=fact5=1; num=0; while(num<=0){ fact1 =fact1+fact1*

No comments:

Post a Comment