Write a c program to find out the sum of series 1 + 2 + …. + n.


Sum of 1 + 2 + ….  + n series in c programming language

#include<stdio.h>
int main(){

    int n,i;
    int sum=0;

    printf("Enter the n i.e. max values of series: ");
    scanf("%d",&n);

    sum = (n * (n + 1)) / 2;

    printf("Sum of the series: ");

    for(i =1;i <= n;i++){
         if (i!=n)
             printf("%d + ",i);
         else
             printf("%d = %d ",i,sum);
         }
   
    return 0;
}

Sample output:

Enter the n i.e. max values of series: 5
Sum of the series: 1 + 2 + 3 + 4 + 5 = 15

Mathematical Formula:



Sum of the series 1 + 2 + 3 + … + n = n (n+1)/2



6. Write a c program to find out the sum of given H.P.

117 comments:

Anonymous said...

give me solution for below series....
0 1 3 6 10 15 21.....n

manti saha said...

0,1,3,10,15,21....n
void main()
{
int i,s=0,n=10;
printf("%d",s);
for(i=1;i<=n;i++)
{
s=s+i;
printf("%d",&s);}
}

hk said...

give me solution for S= 1!+2!+3!+4!+....N!

Anonymous said...

return the sum from 1 to the int argument input, i,e, if the argument is N, return 1+2+3+4....+N????

Anonymous said...

how we'll write a program to find sum of series 1+2-3+4....-n without using "if"..plss help me out...

Anonymous said...

give me a solution for given series:
1+7+13+19+25+..........

Sravanthi T said...

give me solution for 1+2+4+7+11.............

mohammad fuzail said...

Write a „C‟ program to solve the series S = -1+3-11+43-171+….
There is no result found in google
give me the result.

Anonymous said...

#include
long factorial(int n)
{
long p=1;
for(int n=1; i<=n; i++)
p=p*i;
return p;
}
void main(){
int n; long p;
cout<<"Input n:";
cin>>n;
p=factorial(n)
cout<<"Factorial="<<p;
}

sahid islam said...

Write a c program to find out the sum of series 1 + 2 + 4 + 8 … to infinity.using for loop

Pooja Gupta said...

#include
#include
int main()
{
int i,n;
int sum=1;
cout<<"enter the number up to which u want to add : ";
cin>>n;
for(i=1;i<=n;i=i+i)
{
sum=sum+i+i;
}
cout<<"the sum is: "<<sum;
getch();
return 0;
}

abhi said...

some one help me to find the sum of 1+1/2!+1/3!+----- - - -

PRERNA JHA said...

1+2+3+---------------n
#include
#include
void main()
{
int i,n,sum,d;
sum=0,d=1;
printf("Enter the no of term in series: ");
scanf("%d",&n);
for(i =1;i <= n;i++)
{
sum=sum+d;
d=d+1;
}
getch();
}

PRERNA JHA said...

is this write

vipin kumar said...

Give me solution for
1+1/!3+1/!5+1/!7+............

vipin kumar said...

Give me solution for
1+3+3^2+3^3+3^4+....

Rajdeep Rana said...

wht will be d soln for tis 1/2-3/4+5/6-7/8........upto nth term

Pramod Patil said...

$number=25;
$j=0;
for($i=0;$i<=$number;$i+=$j){
$j++;
echo $i.",";

Pramod Patil said...

$number=5;
$p=1;
$total="";
for($i=1;$i<=$number;$i++){
$p*=$i;
echo "1/".$i."!+";
$total+=1/$p;
}
echo "=".$total;

Pramod Patil said...

$number=7;
$p=1;
$total="";
for($i=1;$i<=$number;$i+=2){
$p*=$i;
echo "1/".$i."!+";
$total+=1/$p;
}
echo "=".$total;

Rahul Shakya said...

give me solution for below series....
4 3 2 1
4 3 2
4 3
4

tariq aziz titu said...

summation of this series 1+1/3+1/5+.....+1/299

A S M Kibria Shohan said...

#include
#include
void main()
{
int i,r;
printf("Enter the number range:");
scanf("%d",&r);
for (i=1;i<r;i=i+6)
{
printf("%d ",i);
}
}

ompi said...

int base = 3;
int sum = 1 ;
int prd = 1;
int exp = 2;
for (int i = 1;i<=exp;i++)
{
//int z = 3;
prd = prd*base;
sum = sum +prd;
}
printf("sum =%d",sum);

ompi said...

for(int i=1;i<=4;i++)
{
for(int j=4;j>=i;j--)
{
printf("%d\t",*);
}
printf("\n");
}

Sohab H.H said...

S=1-3+5-7+9.....

prince vishwakarma said...

give me the solution for
1/2+3/4+5/6+....+n

SAGZZZ THE BAD_BOY said...
This comment has been removed by the author.
SAGZZZ THE BAD_BOY said...


int main()
{
int i, j, n;
float sum = 0;

printf("\n Enter the Value of n:");
scanf("%d",&n);

for(i=1, j=1; i<=n; i++, j=j+2)
{
sum = sum+(float)(j)/(j+1);
}

printf("sum= %f",sum);
}

SAGZZZ THE BAD_BOY said...


int main()
{
int i, j, n;
float sum = 0;

printf("\n Enter the Value of n:");
scanf("%d",&n);

for(i=1, j=1; i<=n; i++, j=j+2)
{
sum = sum+(float)(j)/(j+1);
}

printf("sum= %f",sum);
}

sumit kumawat said...


public class First
{

public static void main(String[] args)
{


int s=1;
for(int i=1;i<=5;i++)
{

System.out.println(s);
s=s+i;
}
}
}


sumit kumawat said...

#include
#include
int main()
{
int i,n;
int sum=1;
cout<<"enter the number up to which u want to add : ";
cin>>n;
for(i=1;i<=n;i=i+i)
{
sum=sum+i+i;
}
cout<<"the sum is: "<<sum;
getch();
return 0;
}

Shriram Bubby said...

a c program to display the series 1,2,6,15,31,56 …… N

Gm Zulkar Nine Pranto said...

I am new in program.......................................
give the solation of 1+2+3+4+......................+100=?

Karthick Devan said...



Write a program to generate the first n terms in the series --- 20,19,17,..,10,5
anyone help with this

Maddaiah Polimera said...

#include
#include
void main()
{
int i,n,s=1;
printf("Enter the no of term in series: ");
scanf("%d",&n);
for(i 0;i <= n;i++)
{
s=s+(i*i);
}
printf("%d",s);
getch();
}

Chinmay Gordey said...

int m=20;
for(i=1; i<=n; i++)
{
printf("%d ", m );
m=m-i;
}

Mansi S said...

Program to generate series 3 9 27 81 243

vivek s said...

Write a program to generate the first n terms in the series --- 6,11,21,36,56,...

vivek s said...

can anyone help me for above problem!!

jahid kha said...

write a program to find the sum of series 1+2+3+............+20 using while loop on c program

satya deva Reddy said...

Write a program to generate the first n terms in the series --- 20,19,17,..,10,5

cherry mouni said...

#include

int main()
{
int n,count,x=1,p;

scanf("%d",&n);


printf("%d ",n);

p=n;
for ( count = 2 ; count <= n ; count++ )
{

p=p+(x*(n-1));

x++;
printf("%d ",p);
}



return 0;
}

ritu lia said...

Write a program to generate the first n terms in the series --- 20,19,17,..,10,5

vivek s said...

Thank u :)

gnanam moorthy said...

Write a program for 1/2 + 3/4 + 5/6 +7/8 +.......n

Akshay Putta said...

give me a answr for this
1-2+3-4+5-6+.......n

chandan dips said...

define MAX 100000
void rec(int prev)
{
int curr;
curr=prev*4-1;
printf("%d ",curr);
if (curr<MAX)
rec(curr);
return;
}

int main()
{
rec(0);
//...something else
}

Nahidul Islam said...

1+(1+3)+(1+3+5)+(1+3+5+......n)program in c

Nahidul Islam said...

1+(1+3)+(1+3+5)+(1+3+5+......n)program in c

Mahabub said...

Please give me solution....
1
22
333
4444
55555

Suraj Hariyani said...

i need this series 1 , 0 ,3 ,0 ,

joshua ouano said...

Write the program for summation of numbers from 1 to 5. (Include no. 5, where 1+2+3+4+5)

Unknown said...

Solution for Nth term series :
1,0,1,0,1,0...

anonymus said...

give the string "WORDPROCESSING",write a program to read the string from the terminal and display the same in the following formats:
(a).WORD PROCESSING
(b)WORD
PROCESSING
(c).W.P.

anonymus said...

give the string "WORDPROCESSING",write a program to read the string from the terminal and display the same in the following formats:
(a).WORD PROCESSING
(b)WORD
PROCESSING
(c).W.P.

Gnanam N said...

display the series 1,2,6,15,31,56....N..... plz give crct program

Gnanam N said...

hello frd,
c program to display the series 1,2,6,15,31,56 …… N
plz send program

PONNAM RAMESH said...

use pow ( ) function

Unknown said...

give me solution...with c
1+1+1+1+1+2+3+4+5+6+8+10+12+14+16+19+22+25+....+50=?

San Jose De Buan MPS said...

1 5 8 2 4 9 3 3 10 4 2 11 5 1 12
can anyone help me

aradhna yadav said...

S=1/1+1/2+1/3+1/4...................1/n

aradhna yadav said...

S=1/1+2/2+3/3+4/4+........................n\n

Unknown said...
This comment has been removed by the author.
Md Alamin said...

1.2.4+2.3.6+3.4.8+.....10.11.22

Can anyone help me?

viresh khandelwal said...

nice logic...!

ritu lia said...

Write a program to generate the first n terms in the series --- 2,3,5,7,11,...,17

Input Format:

Input consists of a single integer which corresponds to n.

Output Format:

Output consists of the terms in the series separated by a blank space.



Sample Input:

8

Sample Output:

2 3 5 7 11 13 17 19

sachin jha said...
This comment has been removed by the author.
Harshita Panga said...

value of 4^3^2 using c programming

Harshita Panga said...

value of 4^3^2 using c programming

Unknown said...

can u give me the soln
1/2+3/4+5/6+.......(n-1)/n(where n is as input)

mo khun said...

An original way to calculate the square of a number n
is to make the sum of the first n odd numbers.
Examples:
5^2 = 1+3+5+7+9 = 25
4^2 = 1+3+5+7 = 16
3^2 = 1+3+5 = 9
2^2 = 1+3 = 4
1^2 = 1 = 1

mo khun said...

help me!

shahbaz javed said...

write a program that solve 1!+2!+3!+...........+N!

tell the answer anybody
who is a good programer

shahbaz javed said...

plzzzzzzzzzzzzzz,,,,,,,,,,,,..........

Unknown said...

write a program to get the below output
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

Nanda kishan said...

can any 1 help me out ...im a beginner !

naga kalyan said...

write a c program for fibonacce numbers below 50

Unknown said...

Class series
{
Void fibonacci ()
{
Int a =0, b=1, c, i=3;
System.out.print (a+ "," + b);
do
{
c=a+b;
System.out.print ("," + c);
a=b;
b=c;
i++;
}while (i <=n);
}
}

AMR Gamer said...

Can anyone help me out with this
SUM=2!+4!+6!+...+2n!

A. Shanmugam said...

can you help me to print the series 7,5,8,6,9,.....

অন্ধের আলো said...

a^0+a^1+a^2+............+a^n
where a=3 and n=5. solution needed.

অন্ধের আলো said...
This comment has been removed by the author.
phani kumar said...

1+(2*3)+(4*5*6)+…n

RP said...

Pls give me solution to this........
1/2+3/4+5/6+.....+n

kripal singh said...

Give me solution to this
6,11,21,36,56,81

Unknown said...

Please help me to solve this
Write a program to generate the first n terms in the series --- 3,9,27,81,...,...


Input Format:

Input consists of a single integer which corresponds to n.

Output Format:

Output consists of the terms in the series separated by a blank space.



Sample Input:

6

Sample Output:

3 9 27 81 243 729

Sanhita Lahiri said...

Please help me to solve this
Write a program to generate the first n terms in the series --- 6,11,21,36,56,...


Input Format:

Input consists of a single integer which corresponds to n.

Output Format:

Output consists of the terms in the series separated by a blank space.



Sample Input:

6

Sample Output:

6 11 21 36 56 81

Sanhita Lahiri said...

Please help me to solve this
Write a program to generate the first n terms in the series --- 6,11,21,36,56,...


Input Format:

Input consists of a single integer which corresponds to n.

Output Format:

Output consists of the terms in the series separated by a blank space.



Sample Input:

6

Sample Output:

6 11 21 36 56 81

ompi said...

#include
//#include "stdafx.h"

int main()

{

int n = 6, m = 10;
for(int j = 0; j<= m; j++)
{
n += j*5;
printf("%d\t", n);
}
getchar();
}

ompi said...

#include
#include "stdafx.h"

int main()

{

int n = 6, m = 10;
for(int j = 0; j<= m; j++)
{
n += j*5;
printf("%d\t", n);
}
getchar();
}

ompi said...

#include
//#include "stdafx.h"

int main()

{

int n = 3, m = 1,N = 10;
while(N>0)
{
m *= n ;
printf("%d\t", m);
N--;
}
getchar();
}

Prodigy Sharma said...

#include
int main()
{
int n,i,a=6;
scanf("%d",&i);
printf("%d ",a);
for(n=1;n<=i;n++)
{
a=a+n*5;
if(a<=81)
printf("%d ",a);
else
break;
}
return 0;
}

Unknown said...
This comment has been removed by the author.
synicalsoul said...

another way please where we just input n and printf is once used only

synicalsoul said...

dis u gt the right answer

Barbara Browen said...

Please help me to solve this :

Write a C program which will find the sum of the N-terms of the below
series. The program will consist of a MAIN function and a function.
2^n/n

Within the MAIN function.
• Number of terms N will be read from the standard input.
• N will be passed to the function as an argument.
• Sum of the N terms(return value from the function) will be printed.

Within the function.
• Sum of the N terms of the given series will be calculated and returned
to the MAIN function.

Anand Kumar said...

write a program in c++for that will take a number "n" as input and print the output in that formate if n=3 print in 2 1,1+2=2 1,2+3=3

AHMED SANNY said...

some on plz sum of 1^2+(1^2-3^2)+(1^2-3^2+5^2)+(1^2-3^2+5^2-7^2)......n th series in c programming

AHMED SANNY said...

some on plz sum of 1^2+(1^2-3^2)+(1^2-3^2+5^2)+(1^2-3^2+5^2-7^2)......n th series in c programming

Ashraf Pitu said...

2+5+9+14+....nth

Saiful Islam Sakib said...

Give me a solution for
2*3+3*4+4*5+.....+(n+1)(n+2)
Where 'n' represents the number of tarms

Unknown said...

Write a program to generate the first n terms in the series --- 9,11,20,31,...,82

Sharanya Raja said...

pls give me solution for this
input=45
output should be sum of these digits ..i.e.,4+5=9
if input =542
output should be sum of 5+4+2=11 then it should be again added i.e.,1+1=2

Singh sanu said...

#include
Int main ()
{
Int n, I, add=0;
Printf ("\nEnter a No:");
Scanf ("% d",&n);
for (I=0:I <=n; I++)
add=add+I;
printf ("total no of sum=% d", add);
return 0;
}

Sharanya Raja said...

I got answer for the my previous doubt and program is


#include
#include
void main()
{
unsigned long long int no,num;
int t,sum=0;
clrscr();
printf("\nEnter number");
scanf("%ld",&num);
no=num;
LOOP:while(no)
{
t=no%10;
no=no/10;
sum=sum+t;
}
if(sum>9)
{
no=sum;
sum=0;
goto LOOP;
}
printf("%d",sum);
getch();
}

Result:
input :123456789
output:9

Usha best song ever said...

2,2,4,6,10,16 upto 12 plz help...anyone..

Usha best song ever said...

2,2,4,6,10,16 upto 12 plz help...anyone..

Mary said...

A Pascal number is a number that is the sum of the integers from 1 to j for some j. For example 6 is a Pascal number because 6 = 1 + 2 + 3. Here j is 3. Another Pascal number
is 15 because 15 = 1 + 2 + 3 + 4 + 5. An example of a number that is not a Pascal number is 7 because it falls between the Pascal numbers 6 and 10

Write a function named isPascal that returns 1 if its integer argument is a Pascal number,
otherwise it returns 0.
The signature of the function is
int isPascal (int n)

dj boy said...

How to find season program use menu in c program?

anonymous said...

pls helpm me with this series -1 2 3 6 4 5 6 15 7 8 9

Surendra Batala said...

plz solve this question .
display the series 15,9......up to 20th term.

Unknown said...

Please solve this
Write a program in c to get the sum of series
1+1/2+2/3+3/4.....49/51

Saquib Memon said...

Please solve this
Write a program in c to get the sum of series
1+1/2+2/3+3/4.....49/51

sahil rawat said...

WAP to print and find the sum of the series: 1, 4, 6, 9, 11……… upto n terms.

Unknown said...

Could anyone please post a c program for the series --9 11 20 31 51 82.

Input : 6

Output: 9 11 20 31 51 82

weishin said...

Consider the following series of numbers (for questions 1 and 2)
2,6,11,17,24,32,41,51,62,…n<200

1. Write a java program using while loop that printout the numbers in each iteration.

2. Write a java program using for loop that printout the numbers in each iteration.