Generate the Series

Below coding is the program to generate n number of series.

For example: (1*1)+(2*2)+(3*3)+……+(n*n)

//GENERATING THE SERIES
#include<stdio.h>
#include<conio.h>
void main()
{
 int n,i,sum=1;
 clrscr();
 printf("\n\n\nGenerating the Series\n");
 printf("(1*1)+(2*2)+(3*3)+......+(n*n)\n\nEnter the value of N: ");
 scanf("%d",&n);
 for(i=2;i<=n;i++)
 {
   sum=sum+(i*i);
 }
 printf("\nSum of Series is: %d",sum);
 getch();
}

 

Leave a Reply