2dix-The Student Choice
Log in Register now

C++ Program of SUM OF n numbers, SQUARES,CUBES OF THE SERIES

Write a Program of SUM OF THE SERIES 1+2+3+---------+n

#include<iostream.h> 

#include<conio.h>

void main()
{
int r;
clrscr();
printf("\nEnter the number range: ");
scanf("%d",&r);
printf("\nSum of the series is: %d",(r*(r+1))/2);
getch();
}


SUM OF SQUARES OF THE SERIES 12+22+32+--------+n2


#include<iostream.h> 

#include<conio.h>

void main()
{
long int r;
clrscr();
printf("\nEnter the range: ");
scanf("%ld",&r);
printf("\nSum of the squares of the series is: %ld",((r*(r+1))*(2*r+1))/6);
getch();
}


Write a Program of SUM OF CUBES OF THE SERIES 13+23+33+---------+n3

#include<iostream.h> 

#include<conio.h>

void main()
{
int r;
clrscr();
printf("\nEnter the number range: ");
scanf("%d",&r);
printf("\nSum of the cubes of the series is: %d",(r*(r+1)/2)*(r*(r+1)/2));
getch();
}


Note:
      If you want to change in this program please write through the comment on this page. you can also past similar program 
                 of c++ with output.your comment is valuable to the other user and person.

comments (1)

avatar