bsc

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

root / semester_1 / tuition-c / P031.c

P031.c (937B)


      1 /* Find the sum of the series */
      2 
      3 #include <stdio.h>
      4 #include <math.h>
      5 
      6 int main()
      7 {
      8     double a, res, n;
      9     int i;
     10 
     11     // s = (a ^ 2) + (a ^ 2 / 2) + (a ^ 2 / 3) + ... + (a ^ 2 / 10)
     12     {
     13         res = 0, i = 1;
     14         printf("--- s = (a ^ 2) + (a ^ 2 / 2) + (a ^ 2 / 3) + ... + (a ^ 2 / 10) ---");
     15         printf("\nEnter the number : ");
     16         scanf("%lf", &a);
     17         while (i <= 10)
     18         {
     19             res = res + ((a * a) / i);
     20             i++;
     21         }
     22         printf("S = %g", res);
     23     }
     24 
     25     // s = 1 + (2 ^ 2 / a) + (3 ^ 3 / a ^ 2) + ... + n
     26     {
     27         res = 0, i = 0;
     28         printf("\n--- // s = 1 + (2 ^ 2 / a) + (3 ^ 3 / a ^ 2) + ... + n ---");
     29         printf("\nEnter the value for a and n : ");
     30         scanf(" %lf %lf", &a, &n);
     31         while (i <= n - 1)
     32         {
     33             res = res + (pow(i + 1, i + 1) / pow(a, i));
     34             i++;
     35         }
     36         printf("S = %g", res);
     37     }
     38 
     39     return 0;
     40 }
© 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