By Ramarathna PaVaN Kumar.....
My Pages..
Home
C - Programming
JoKe$
Sunday, November 28, 2010
Find the sum of all odd no.’s from 0 to 100 using function recursion.
#include
int odd(int n,int sum)
{
if (n%2==1)
sum = sum+n;
if (n==100)
return sum;
return odd(n+1,sum);
}
main()
{
printf("sum is %d\n",odd(1,0));
}
Newer Post
Older Post
Home