Monday, September 12, 2011

sum of two numbers using Recursion

//sum of two numbers using Recursion
#include<stdio.h>
#include<conio.h>
main()
{
    int a,b,i;
    clrscr();
    printf("\nEnter two non-negative nos.:");
    scanf("%d %d",&a,&b);
    printf("\n Sum of the given nos=%d",sum(a,b));
    getch();
}

    sum(int c,int d)
    {
      if(c==0)
        return(d);
      else
        sum(--c,++d);
    }


No comments:

Post a Comment

Popular 5 Posts Last 7 days