Saved Bookmarks
| 1. |
• Write a program to print the sum of the first n terms of the following series1/2 - 1/4 + 16 -1/8 +... |
|
Answer» 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); else 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 |
|