2. (a) Write a C program to find the sum of the following series upto 20 terms 1+ 4 +7 +10 +13..............

, , No Comments

 C Program to Find Sum of the Series (1 + 4 + 7 + ... up to 20 terms)

#include <stdio.h>

int main() {

int n = 20;
int Sum = 0;
int Term 1; 
for(i = 1; i <= 20; i++) {
 sum += term;

  term += 3;         // Next term (add common difference)

    }

    // Print the result

    printf("Sum of the series up to 20 terms is: %d\n", sum);


    return 0;

}

0 टिप्पणियाँ:

Post a Comment