C Language "Sum of Given series 1^1+2^2+3^3+.......+n^2 using for loop" program with output

 #include <stdio.h>

int main() { int n; printf("Enter the value of n: "); scanf("%d", &n); long long sum = 0; for (int i = 1; i <= n; i++) { long long term = 1; for (int j = 1; j <= i; j++) { term *= i; // Calculate i^i } sum += term; // Add the term to the sum } printf("Sum of the series 1^1 + 2^2 + 3^3 + ... + %d^%d is %lld\n", n, n, sum); return 0; }


Output:
Enter the value of n: 5 Sum of the series 1^1 + 2^2 + 3^3 + ... + 5^5 is 3413

Comments

Popular posts from this blog

Video Formats

Where video editing is used

File saving and folder management