Write a program which reads a positive integer value n, calculates and shows the result of the expression: $$\sum_{i=1}^{n}\frac{i+3}{i^2-5}$$
Difficulty level
Video recording
This exercise is mostly suitable for students
#include<stdio.h>
#include<conio.h>
int main()
{
int N, i ;
double sum;
sum = 0;
do{
printf("Enter an integer: ");
scanf("%d", &N);
}while(N <0);
// denominator could never be equal to 0
for(i=1; i <=N; i+=3)
sum+= (double)(i+3) / (i*i - 5);
printf("Sum = %lf \n", sum);
return 0;
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Check divisibility by 2 and 3