Program for evaluate the expression 1 + ½ + 1/3 + ¼ + ……………+ 1/n ( sum of series)
https://www.computersprofessor.com/2016/06/program-for-evaluate-expression-1-13-1n.html
1
+ ½ + 1/3 + ¼ + ……………+ 1/n ( sum of series)
# include <stdio.h>
#include<conio.h>
main
( )
{
int
i , n ;
float
s = 0;
printf
( “enter how many times”);
scanf
(“%d”, & n);
for
( i = 1; i < =n; i ++)
{
s= s+ 1.0/ i;
}
printf
( “\n % 0.2f “, s);
getch
( );
}
Out
Put:
Enter
how many times 6
2.45
|