bsc

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

root / semester_1 / tuition-c / P030.c

P030.c (1008B)


      1 /* Display the first 15 terms of the series. */
      2 
      3 #include <stdio.h>
      4 #include <math.h>
      5 
      6 int main()
      7 {
      8     int i, r;
      9 
     10     // 3, 6, 9, 12, ...
     11     {
     12         i = 3, r = 0;
     13         printf("Series 1 (3, 6, 9, 12, ...) :");
     14         while (i <= 15)
     15         {
     16             r = r + 3;
     17             printf("  %d", r);
     18             i++;
     19         }
     20     }
     21 
     22     // 1, 4, 9, 16, ...
     23     {
     24         i = 1;
     25         printf("\nSeries 2 (1, 4, 9, 16, ...) :");
     26         while (i <= 15)
     27         {
     28             printf("  %d", i * i);
     29             i++;
     30         }
     31     }
     32 
     33     // 4, 8, 16, 32, ...
     34     {
     35         i = 1, r = 2;
     36         printf("\nSeries 3 (4, 8, 16, 32, ...) :");
     37         while (i <= 15)
     38         {
     39             r = r * 2;
     40             printf("  %d", r);
     41             i++;
     42         }
     43     }
     44 
     45     // 0, 7, 26, ...
     46     {
     47         i = 1, r;
     48         printf("\nSeries 4 (0, 7, 26, ...) :");
     49         while (i <= 15)
     50         {
     51             r = (int)pow(i, 3) - 1;
     52             printf("  %d", r);
     53             i++;
     54         }
     55     }
     56 
     57     return 0;
     58 }
© 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