//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);
}
#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