Brijmohan lal Sahu - Facebook
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu
Showing posts with label square series sum. Show all posts
Showing posts with label square series sum. Show all posts

Sunday, December 7, 2014

Program to calculate sum of square series using while loop in C.


sum of square series using while loop



Code Box
---------------------------------------

/*program to calculate sum of the series 
(1*1)+(2*2)+(3*3)+(4*4)+.......+(n*n).
Square number series. 
where n is the limit entered by user.
*/

#include<stdio.h>
#include<conio.h>
void main()
{
int i,sum,num;

clrscr();

sum=0;

printf("\nEnter limit : ");
scanf("%d",&num);

printf("\nSquare Number Series ");

printf("\nSeries= ");

i=1;                   //initialization 

while(i<=num)
{
sum=sum+(i*i);
printf("+ (%d*%d)",i,i);

i++;       // increment post fix operator 

}

printf("\n\nSum of series= %d",sum);

getch();
}


Program to calculate sum of the square series using power function and for loop in C.


square sum using power function


Code Box
-------------------------------------------------

/*program to calculate sum of the series 
(1*1)+(2*2)+(3*3)+(4*4)+.......+(n*n).
Square number series. 
by using power function.
where n is the limit entered by user.
*/

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int i,sum,num;

clrscr();

sum=0;

printf("\nEnter limit : ");
scanf("%d",&num);

printf("\nSquare Number Series ");

printf("\nSeries= ");
for(i=1;i<=num;i++)
{
sum=sum+pow(i,2);
printf("+ (%d*%d)",i,i);
}

printf("\n\nSum of series= %d",sum);

getch();
}



Program to calculate the sum of square series using for loop in C.


square series sum


Code Box
---------------------------------------------------

/*program to calculate sum of the series 
(1*1)+(2*2)+(3*3)+(4*4)+.......+(n*n).
Square number series. 
where n is the limit entered by user.
*/

#include<stdio.h>
#include<conio.h>
void main()
{
int i,sum,num;

clrscr();

sum=0;

printf("\nEnter limit : ");
scanf("%d",&num);

printf("\nSquare Number Series ");

printf("\nSeries= ");
for(i=1;i<=num;i++)
{
sum=sum+(i*i);
printf("+ (%d*%d)",i,i);
}

printf("\n\nSum of series= %d",sum);

getch();
}