Find sum of Expanded Geometric Sequence - C

Write a C program to find sum of given series (expanded geometric sequence) upto n terms.

1 + 1/4 + 1/9 + 1/16 + ........ + 1/N


Solution:

#include<stdio.h>
int main()
{  
      int n,i,sqr;
      float s;
      printf("1+1/4+1/9+1/16+....+1/N");
      printf("\n\nEnter Value of N : ");
      scanf("%d",&n);
      for(i=1;i<=n;i++)
      {
            sqr=i*i;
            s=s+(1/(float)i);
            /* For printing the series */
            if(i==1)
                  printf("\n1 +");
            else if(i==n)
                  printf("(1/%d)  ",sqr);
            else
                  printf(" (1/%d) + ",sqr);
      }
      printf("\n\nSum of Series = %.2f",s);
      return 0;        
}


Output:

expanded geometric sequence