18 lines
345 B
C
18 lines
345 B
C
#include<stdio.h>
|
|
#include<conio.h>
|
|
void main() {
|
|
int n;
|
|
float i, sum, t;
|
|
printf("1+1/2+1/3+......+1/n\n");
|
|
printf("Enter the value of n\n");
|
|
scanf("%d",&
|
|
amp;
|
|
n);
|
|
sum=0;
|
|
for (i=1;i<=n;i++) {
|
|
t=1/i;
|
|
sum=sum+t;
|
|
}
|
|
printf("%f",sum);
|
|
getch();
|
|
} |