vendredi 14 décembre 2018

What is the error?Q-To determine and print the sum of the following harmonic series for a given value of n.(1+1/2+1/3+........+1/n)

void main()
{

int n,i;  
        printf("enter number");  
        scanf("%d",&n);  
        float s=0;  
        for(i=1;i<=n;i++)  
        {  
        s=s+(1/i);  
        }  
    printf("sum is %f",s);  
    }  

I'm getting an output of 1.00. Why?

Aucun commentaire:

Enregistrer un commentaire