A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

C program to find the sum of series 1.2/3 + 2.3/4 + 3.4/5 + 4.5/6 + ... + n(n +1)/(n+2)
Q:

C program to find the sum of series 1.2/3 + 2.3/4 + 3.4/5 + 4.5/6 + ... + n(n +1)/(n+2)

0

C program to find the sum of series 1.2/3 + 2.3/4 + 3.4/5 + 4.5/6 + ... + n(n +1)/(n+2)

Given the value of n and we have to find the sum of series 1.2/3 + 2.3/4 + 3.4/5 + 4.5/6 + ... + n(n +1)/(n+2) Using C program.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program to find the sum of series 1.2/3 + 2.3/4 + 3.4/5 + 4.5/6 + ... + n(n +1)/(n+2) in C

/*  
C program to find sum of following series
* 1.2/3 + 2.3/4 + 3.4/5 + 4.5/6 + ... + n(n +1)/(n+2)
*/

#include <stdio.h>
#include <math.h>

// main function
int main()
{
	int i,N,x;
	float sum;
	
	/*read value of N*/
	printf("Enter total number of terms: ");
	scanf("%d",&N);
	
	/*set sum by 0*/
	sum=0.0f;
	
	/*calculate sum of the series*/
	for(i=1;i<=N;i++)
	{
		sum = sum + ( (float)(N)*(N+1) / (float)(N+2));
	}
	
	/*print the sum*/
	printf("Sum of the series is: %f\n",sum);
	
	return 0;
}

Output

Run(1)
Enter total number of terms: 3
Sum of the series is: 7.200000

Run(2)
Enter total number of terms: 4
Sum of the series is: 13.333333

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now