c program to find sum of array elements using recursion
int sum(int arr[], int start, int len)
{
// Recursion base condition
if(start >= len)
return 0;
return (arr[start] + sum(arr, start + 1, len));
c program to find sum of array elements using recursion
int sum(int arr[], int start, int len)
{
// Recursion base condition
if(start >= len)
return 0;
return (arr[start] + sum(arr, start + 1, len));
c program to find the sum of given number using recursion
# include <stdio.h>
int sum(int number);
int main
{
int n;
int a;
printf("enter a number");
scanf("%d,&n);
a=sum(n);
printf("sum=%d",a);
}
int sum(int number)
{
if (number==0)
return 0;
return(number%10+sum(number/10);
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us