Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

" ; " after loop



Working with switch case



Specifer



Test expression



Comment




Calculate Summation of this series 1 + 1/5 + 1/9 + 1/13 + ...... + 1/x



// AHF C PROGRAM SOLVING

//solving here ITERATIVES STATEMENTS type of programming problem

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


© 2018 - All rights reserved