S= 1*2 + 2*3 + 3*4 + ……..+ n * (n+1) solve the equation [ loop series ]

 



#include<stdio.h>
#include<conio.h>
#include<math.h>
int main(int argc, char const *argv[])
{
  int x,n,i;
  float m,c,y,sum=0;

  printf("enter the value of  n :");
  scanf(" %d",&n);

  
  for ( i = 1; i <= n; i++)
  {
    y=i*(i+1);
    printf(" %f",y);
    sum=sum+y;
  }

    m=sum;
  printf("\nsum of series = %f",m);
  return 0;


}

output :

enter the value of n :8 2.000000 6.000000 12.000000 20.000000 30.000000 42.000000 56.000000 72.000000 sum of series = 240.000000

Comments

Popular Post

Write the definition for a class called complex that has floating point data members for storing real and imaginary parts. The class has the following member functions: void set(float, float) to set the specified value in object void disp() to display complex number object complex sum(complex) to sum two complex numbers & return complex number 1. Write the definitions for each of the above member functions. 2. Write main function to create three complex number objects. Set the value in two objects and call sum() to calculate sum and assign it in third object. Display all complex numbers.