Write a c program to find 1+1/2+1/3+1/4+...+1/n
#include <stdio.h>
#include <conio.h>
void main()
{
int n, j;
long float sum = 0;
clrscr();
printf("Enter the value of n: ");
scanf("%d", &n);
for (j = 1; j <= n; j++)
{
sum = sum + 1 / (float)j;
}
printf("Answer %lf", sum);
getch();
}
Thank you for visiting seeya again
No comments:
Post a Comment