Saved Bookmarks
| 1. |
• Write a program to print the sum of the first n terms of the following series 1/2 - 1/4 + 16 -1/8 +... |
|
Answer» ong>Answer: void sum (int terms) { float sum = 0.0, j = 1.0; int count; for(count = 1; count <= terms; count++) { sum = sum + (1/j); if(count%2 == 0) j = j * (-2); j = j * 2; } printf("\nSum of Series:\t %f", sum); printf("\n"); return 0; } int MAIN () { int numberOfTerms = 5; sum(numberOfTerms); return 0; } Explanation: Hope this HELPS |
|