Home Basic Loop Array string Function Pointer Contact STUDY

AHF    C    PROGRAM    SOLVING

Programming tips

" ; " after loop



Comment



Test expression



Iterative statement



Working with switch case




Calculate Summation of this series 1 + 1/2 + 1/3 + ...... + 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++) { //calculating as given in the series and assigning temp temp=1/i; //value of the temp is adding with res variable sum+=temp; } pf("\nThe summation of the series is: %f",sum); return 0; }
OUTPUT:


© 2018 - All rights reserved