Sum the Series

Write a C program to Calculate the below Series. The Value of x and n must take from input terminal.

 1.    Sum = x + x2 + x3 +…. +  xn

 2.   Sum = x + 2x + 3x +…. +  nx

 3.   Sum=x1 + x1/2 + x1/3  + ….  +  x1/n


1.

#include

main()
{
int x, n, I, sum=0, y;

scanf("%d %d", &x, &n);
y=x;
for(I=1;I<=n;I++)
{
if(I==1)
{
printf("\n%d+", x);
}
else if(I==n)
{
printf("%d^%d = ", x, n);
}
else
{
printf("%d^%d+", x, I);
}
sum+=y;
y=y*x;
}
printf("%d", sum);

getch();
return 0;
}

2.                                                                                                                                                                   

#include

main()
{
int x, n, I, sum=0;

scanf("%d %d", &x, &n);
for(I=1;I<=n;I++)
{
if(I==1)
{
printf("\n%d+", x);
}
else if(I==n)
{
printf("%dx%d = ", n, x);
}
else
{
printf("%dx%d+", I, x);
}
sum+=I*x;
}
printf("%d", sum);

getch();
return 0;
}

3.                                                                                                                                                                  

#include

main()
{
int x, n, I;
float sum=0;

scanf("%d %d", &x, &n);
for(I=1;I<=n;I++)
{
if(I==1)
{
printf("\n%d+", x);
}
else if(I==n)
{
printf("%d^(1/%d) = ", x, n);
}
else
{
printf("%d^(1/%d)+", x, I);
}
sum+=pow(x, (1.0/I));
}
printf("%.2f", sum);

getch();
return 0;
}

7 মন্তব্যসমূহ

  1. 1.

    #include

    main()
    {
    int x, n, I, sum=0, y;

    scanf("%d %d", &x, &n);
    y=x;
    for(I=1;I<=n;I++)
    {
    if(I==1)
    {
    printf("\n%d+", x);
    }
    else if(I==n)
    {
    printf("%d^%d = ", x, n);
    }
    else
    {
    printf("%d^%d+", x, I);
    }
    sum+=y;
    y=y*x;
    }
    printf("%d", sum);

    getch();
    return 0;
    }

    উত্তরমুছুন
  2. 2.

    #include

    main()
    {
    int x, n, I, sum=0;

    scanf("%d %d", &x, &n);
    for(I=1;I<=n;I++)
    {
    if(I==1)
    {
    printf("\n%d+", x);
    }
    else if(I==n)
    {
    printf("%dx%d = ", n, x);
    }
    else
    {
    printf("%dx%d+", I, x);
    }
    sum+=I*x;
    }
    printf("%d", sum);

    getch();
    return 0;
    }

    উত্তরমুছুন
  3. 3.

    #include

    main()
    {
    int x, n, I;
    float sum=0;

    scanf("%d %d", &x, &n);
    for(I=1;I<=n;I++)
    {
    if(I==1)
    {
    printf("\n%d+", x);
    }
    else if(I==n)
    {
    printf("%d^(1/%d) = ", x, n);
    }
    else
    {
    printf("%d^(1/%d)+", x, I);
    }
    sum+=pow(x, (1.0/I));
    }
    printf("%.2f", sum);

    getch();
    return 0;
    }

    উত্তরমুছুন
  4. Md. Mahfuzur Rahman vai apni tyo sudu copy and past koran...Nijea aktu try koran na notun Solution detea...best of luck..

    উত্তরমুছুন
  5. Md. Faizul Haque Nayan, amar code jokhon post korechi tokhon kono sudo code dewa hoto na. so sudo code copy paste korar prosnoi ashe na. Understood ? na bujhle bolen. r akbar boli...

    উত্তরমুছুন
  6. o ter manea apni boltea chan sir apner code copy past korea..valo kotha e bolsea...apner kotha amr onok din monea thakbea..

    উত্তরমুছুন

  7. #include

    main()
    {
    int x, n, I;
    float sum=0;

    scanf("%d %d", &x, &n);
    for(I=1;I<=n;I++)
    {
    if(I==1)
    {
    printf("\n%d+", x);
    }
    else if(I==n)
    {
    printf("%d^(1/%d) = ", x, n);
    }
    else
    {
    printf("%d^(1/%d)+", x, I);
    }
    sum+=pow(x, (1.0/I));
    }
    printf("%.2f", sum);

    getch();
    return 0;
    }

    উত্তরমুছুন
নবীনতর পূর্বতন