Jan

17

#include<conio.h>
#include<stdio.h>
int sum(int);
void main(){
int num;
printf(“Enter number to get num till: “);
scanf(“%d”,&num);
num=sum(num);
printf(“Sum is: %d”,num);
}
int sum(int n){
if (n==1)
return n;
else
return (n+sum(n-1));
}


Leave a Reply

Filled Under: C Programming