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.

121 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);}
}

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+..........

Unknown said...

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

Unknown 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;
}

Unknown said...

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

Unknown 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!+----- - - -

Unknown 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();
}

Unknown said...

is this write

vipin said...

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

vipin said...

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

Anonymous 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;

Unknown said...

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

Unknown said...

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

Unknown 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");
}

Dr. JustMAD said...

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

Unknown said...

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

Sagar Narkar said...
This comment has been removed by the author.
Sagar Narkar 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);
}

Sagar Narkar 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;
}
}
}


Unknown 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;
}

Unknown said...

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

Unknown said...

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

Unknown said...



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

Unknown 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();
}

Unknown said...

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

Unknown said...

Program to generate series 3 9 27 81 243

Unknown said...

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

Unknown said...

can anyone help me for above problem!!

Unknown said...

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

Unknown 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;
}

Unknown said...

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

Unknown said...

Thank u :)

Unknown said...

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

akshay.putta3@gmail.com said...

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

Unknown 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
}

Unknown said...

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

Unknown 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

Unknown said...

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

Unknown said...

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

Programmer 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.

Unknown said...

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

Unknown said...

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

Unknown 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=?

Unknown said...

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

Unknown said...

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

Unknown said...

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

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

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

Can anyone help me?

viresh khandelwal said...

nice logic...!

Unknown 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 said...
This comment has been removed by the author.
Unknown said...

value of 4^3^2 using c programming

Unknown 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)

Unknown 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

Unknown said...

help me!

Unknown said...

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

tell the answer anybody
who is a good programer

Unknown 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

Unknown said...

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

Unknown 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);
}
}

Unknown said...

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

Unknown said...

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

Unknown said...

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

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

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

RP said...

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

Unknown 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

Unknown 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

Unknown 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();
}

Unknown 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

Unknown 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.

Unknown 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

Unknown 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

Unknown 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

Unknown 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

Unknown 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

Unknown 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;
}

Unknown 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

Unknown said...

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

Unknown 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

Unknown 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

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

Sahil 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.

Unknown said...

What will be the code for 2/2!-6/4!+12/6!-20/8!+.........upto N term ic C

Unknown said...

1+4+7+10+13...
plz solve this

Unknown said...

WAP to display the series: 1 6 11 16 21 nth term plz fast

DanaOnline said...

1

dewisari said...

Yuk di add pin WA: +628122222995
Sabung ayam online dan semua jenis permainan judi online ..
Semua bonus menarik kami berikan setiap hari nya ... :)
www,bolavita, ltd s1288 sabung ayam