You are on page 1of 8

C PROGRAMMING: LAB ACTIVITIES

EXERCISE 1: Step 1: Identify Problem Problem Identification Data Volume of the pyramid in smaller version? 1. The height of pyramid is 138.74 metres. 2. The length of base side is 230.37 metres. 3. The formula of volume is 1/3*length of base*width of base*height. Calculate the volume of pyramid with by use the formula.

Solution

Step 2: Analyze Problem using IPO approach Input 1. Height of Giza Pyramid, H. 2. Width base side of Giza Pyramid, W. 3. Length of base side of Giza Pyramid, L. Calculate the volume, V of a pyramid by formula. V=1/3*H*W*L The volume of pyramid.

Process Output Step 3: Designing Algorithm (1) Pseudo Code 1. Start 2. Read height of pyramid, H 3. Read width of base side of pyramid, W 4. Read length of base side of pyramid, L 5. Compute volume, V=1/3*H*L*W 6. Displays the volume of pyramid 7. End

(2) Flow Chart

Start

Read height, H

Read width, W Compute formula V=1/3*L*W*H

End

Read length, L

Display the volume of pyramid

Exercise 2: Step 1: Identify Problem Problem Identification Data How much need to pay to buy leather handbag? 1. Price is RM 399 2. Get 20% discount if become an agent 3. Pay RM 50 to obtain membership card Calculate the new price need to pay.

Solution

Step 2: Analyze Problem using IPO approach Input 1. Price of leather handbag is RM399 2. Price for to obtain membership card is RM 50 3. 20% discount if an agent Calculate the new price New price that need to pay to buy leather handbag

Process Output

Step 3: Designing Algorithm (1) Pseudo Chart 1. Start 2. Read price of leather handbag, LH is RM 399 3. Read price of to obtain membership card, MC is RM 50 4. Read the 20% discount if become an agent 5. Compute the price 6. Displays the new price that need to pay 7. End

(2)Flow Chart Start

Read price LH

Read price MC Read price discount Compute the new price

End

Exercise 3: Step 1: Identify Problem Problem Identification Data Solution Does Sarah to be hired for the personnel assistance position or not? 1. The marks in personality test >50. 2. The marks in the interview=70 Sarah need sit the personality exam paper and pass before interview.

Step 2: Analyze Problem using IPO approach Input Process Marks in personality test, PT and marks in interview, I 1. Calculate the total marks in personality test by adding marks interview. MARK=PT+I. 2. If marks PT >50 and marks I >70 print not to be hired the position. 3. If marks PT <50 and marks I< =70 print to be hired the position. The result if Sarah to be hired or not the personnel assistance position.

Output

Step 3: Designing Algorithm (1)Pseudo Code 1. Start 2. Read marks in personality test, PT 3. Read marks in interview. I 4. Compute the total marks, MARK=PT+I 5. If marks PT <50 + I <=70, print to be hired the position else print not to be hired the position. 6. End

(2)Flow Chart Start

Read PT

Read I

Compute MARK=PT+I

Marks PT<50 + I<=70? Yes Print HIRED

No Print NOT HIRED

End

Exercise 4: Step 1: Identify Problem Problem Identification Data How much new credit limits for customer during period recession? 1. The credit limits is cut in half. 2. Provide account number, credit limit before recession and current balance in account receivable. Calculate and determine new credit limits.

Solution

Step 2: Analyze Problem using IPO approach Input Process Output 1. Provide account number, AN 2. Credit limit before recession, CR 3. Current balance in account, CB Calculate new credit limit and determine the current balance for each customer New credit limit and current balance for each customer.

Step 3: Designing Algorithm (1)Pseudo Code 1. Start 2. Read account number, AN 3. Read credit limit before recession, CR 4. Read current balance in account, CB 5. Compute the new credit limit and current balance for each customer 6. Print the credit limit and current balance for each customer 7. End

(2)Flow Chart Start

Read AN

Read CR

Read CB

Compute the CR and CB

Print new CR and CB

End