Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

Test expression



Header file



Iterative statement



Specifer



Comment




Calculate Summation of this series 1/2 + 2/3 + ...... + x/(x+1)



// AHF C PROGRAM SOLVING

//solving here ITERATIVES STATEMENTS type of programming problem

#include<stdio.h> #include<math.h> #define pf printf int main() { int a; float i,res=0.0,temp; //taking the number to continue loop pf("Enter any number: "); scanf("%d",&a); for(i=1.0;i<=a;i++) { float temp=0.0; temp=i/(i+1); //calculating as given in the series and assigning temp res+=temp; //value of the temp is adding with res variable } pf("\nThe summation of the series is: %f",res); return 0; }
OUTPUT:


© 2018 - All rights reserved