Program for evaluate the expression 1 + ½ + 1/3 + ¼ + ……………+ 1/n ( sum of series)

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


Related

C Programs 8220822105676975490

Post a Comment

emo-but-icon

item