Write a program to calculate the sum of the following series:
1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6 + 1/7 + ... + 1/20
#include <stdio.h> int main(void) { double sum=0.0;//Summ for(int i=1;i<=20;i++) { sum+=(1.0)/(i*1.0); printf("1/%i",i); if(i!=20) printf("+"); } printf("=%lf\n",sum); return 0; }
Need a fast expert's response?
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Comments