Series-1

Click on read more

(1 + 1/2 + 1/3 +......+ 1/n)

#include<stdio.h>
#include<conio.h>
void main()
{
 int i,n;
 float s=0;
 clrscr();
 printf("Enter the value:");
 scanf("%d",&n);
 for(i=1;i<=n;i++)
 {
  s+=1/i;
 }
 printf("Sum is %d",s);
 getch();
}

OUTPUT:
Enter the value:4
2.0833333333

Comments

Post a Comment