bsc

Comprehensive codebase and cou...
Log | Files | Refs | Activity | README | LICENSE

root / semester_1 / letusc / luc050.c

luc050.c (553B)


      1 /* Write a recursive function to obtain the sum of first 25 natural numbers.
      2 */
      3 /* Let Us C, Chap- 10 (Recursive), Qn No.: B(b) */
      4 /* This file is auto-generated by a bot. */
      5 /* This code is not compiled; it is for reference only. */
      6 
      7 
      8 #include <stdio.h>
      9 #include <math.h>
     10 #include <stdlib.h>
     11 
     12 int get_sum(int);
     13 
     14 int main()
     15 {
     16     int n = 25, sum;
     17 
     18     sum = get_sum(n);
     19     printf("Sum of first %d natural numbers is: %d\n", n, sum);
     20 
     21     return 0;
     22 }
     23 
     24 int get_sum(int n)
     25 {
     26     if (n == 0)
     27         return 0;
     28     else
     29         return n + get_sum(n - 1);
     30 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror