ICS 101 - Computer programming

Lab # 8

(DO LOOP)

 

Objectives

 

 

Syntax

 

 

 

 

 

 

 

 

 

 

Exercise 1

 

Write a  program which calculates and prints the sum of the first 300 terms of the infinite series:

 

      2       5       8       11               

     ---  +  ---  +  ---  +  ---- +  . . .  

      2       6       10      14 

 

Your output should be:

            SUM  =  225.958400

 

 

 

Exercise 2

 

Write a program that finds an approximation for PI using the first 10000 terms of the following infinite series:

 

            6          6         6                      

p2  =   ----  +   ----  +   ----    +  . . .  

           12        22        32       

 

your output should be:

 

PI  =   3.141363

 

 

 

Exercise 3

 

Write a program, which uses a do-loop to find the sum of the following series:

 

1   +   (1 * 2)   +   (1 * 2 * 3)   +   (1 * 2 * 3 * 4)   +   . . .  +   (1 * 2 * 3 * . . . * 20)

 

Your output should be:

SUM  = 2.561327E+18

 

 

 

Exercise 4

 

Write a program which finds the sum of the following series:

  ___        ______         __________                     ___________________

       1   +     1  +  2   +     1  +  2  +  3   +   .  .  .  +     1  +  2  +  .  .  .  +  100

 

Your output should be:

 

SUM  = 3605.837000