recent

c program for sum of following series


 c program for sum of following series
[(1^1)/1] + [(2^2)/2] + [(3^3)/3] + [(4^4)/4] + [(5^5)/5] + ... + [(n^n)/n]


#include<stdio.h>
long power(int x, int y)
{
    long j, pow=1;
    for(j=1;j<=y;j++)
    {
        pow=pow*x;
    }
    return pow;
}

int main()
{
    long j,n;
    double sum=0;
    n=5;
    for(j=1;j<=n;j++)
    {
        sum=sum+(power(j,j)/j);
    }
    printf("Sum is: %lf",sum);
}
Powered by Blogger.