Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int sum(int);
- int main()
- {
- int num;
- printf("Enter the Number: ");
- scanf("%d", &num);
- printf("Sum = %d", sum(num));
- return 0;
- }
- int sum(int n)
- {
- if (n == 0)
- return 0;
- else
- return n + sum(n - 1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement