I have tried to code the following harmonic series as below but the progrma outputs 1.000000 only, could someone point out where the flaw is ?
1+1/2+1/3+...........+1/n
Code:#include<stdio.h> #include<conio.h> void main() { int n,deno; printf("enter the value of n"); scanf("%d",&n); deno=1; float sum = 0; while(deno<=n) { sum=sum+(1/deno); deno++ ) printf("%f",sum); getch() }