WAP TO DISPLAY A SERIES AND ITS SUM

/*WAP TO DISPLAY A SERIES AND ITS SUM*/
#include<stdio.h>
#include<conio.h>
void main()
{
int n,i;
float j,inv,sum=0;
clrscr();
printf(“Enter the range: “);
scanf(“%d”,&n);
printf(“Series upto %d and its sum is: \n”,n);
for(j=1;j<=n;j++)
{
i=j;
printf(“1/%d”,i);
if(i<n)
printf(” + “);
inv=1/j;
sum=sum+inv;
}
printf(” = %f”,sum);
getch();
}

Leave a Reply

Your email address will not be published. Required fields are marked *