GoogelAddUnit1

Monday, 16 April 2012

WRITE A C-PROGRAM TO FIND THE SUM OF ANY TWO NUMBERS USING RECURRSION.

WRITE A  C-PROGRAM TO FIND THE SUM OF ANY TWO NUMBERS USING RECURRSION.
AIM:A program to find the sum of any two number using recurrsion.
PROGRAM:
#include<stdio.h>
main()
{
int a,b,k;
printf("enter the values of a,b");
scanf("%d%d",&a,&b);
k=sum(a,b);
printf("sum=%d",k);
}
sum(a,b)
int a,b;
{
if(a==0)
return(b);
else
sum(--a,++b);
}
OUTPUT:
enter the values of a,b
30,20
sum=50

No comments:

Post a Comment