Advertisement
aiNayan

7(iii)

Dec 7th, 2020
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. #include <stdio.h>
  2. int sum(int);
  3. int main()
  4. {
  5. int num;
  6. printf("Enter the Number: ");
  7. scanf("%d", &num);
  8. printf("Sum = %d", sum(num));
  9. return 0;
  10. }
  11.  
  12. int sum(int n)
  13. {
  14. if (n == 0)
  15. return 0;
  16. else
  17. return n + sum(n - 1);
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement