C Program to add First 25 Numbers using Recursion

#include<stdio.h>
#include<conio.h>
int sum(int);
int main()
{
int x,y=0;
clrscr();
x=sum(y);
printf("Sum = %d",x);
getch();
return 0;
}
int sum(int i)
{
 if(i>25)
  {
   return (0);
  }
  else
  {
  while(i<=25)
  {
  return( i+sum(i+1));
  }
  }
}

OUTPUT:-

recursion

Leave a Reply

Your email address will not be published. Required fields are marked *