Code Box
----------------------------------------------
/*Program to calculate sum of series
1/(1*2)+1/(2*3)+1/(3*4)+.......+1/((n-1)*n)
where n is the value entered by user.
=>Explicit type conversion
=>Nested loop
*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int i,n;
float sum,mul;
clrscr();
sum=0;
printf("\nEnter limit number : ");
scanf("%d",&n);
printf("\nSeries=");
printf("\n---------------------\n");
for(i=1;i<n;i++)
{
mul=i*(i+1);
printf(" +1/(%d*%d) ",i,i+1);
sum=sum+(float)1/mul; //Explicit type conversion
}
printf("\n---------------------\n");
printf("\nSum of series= %.3f",sum);
getch();
}