Program to finding sum of 1/2+2/3+3/4+………….n/n+1

0
23
#include<stdio.h>
#include<conio.h>
void main()
{
 int n,i;
 float s=0;  /* s for sum which is a float value as division occurs */
 clrscr();
 printf("\n Enter n\n");
 scanf("%d", &n);
     for(i=1;i<=n; ++i)
         s=s+i/(i+1.0);   /* 1.0 because we have make it float value otherwise
                                    result becomes 0 */
 printf("sum of series = %.3f\n",s);
 getch();
}
    Output:
    Enter n
    10
    sum of the series=7.980

 

 

 

Program to finding sum of 1/2+2/3+3/4+………….n/n+1 Program to finding sum of 1/2+2/3+3/4+………….n/n+1 in c C Program to finding sum of 1/2+2/3+3/4+………….n/n+1 for loop program in c for loop example in c for loop program

LEAVE A REPLY

Please enter your comment!
Please enter your name here