50% found this document useful (2 votes)
490 views4 pages

CBCP2101 - Computer Programming I

This document contains information about a computer programming course, including the student's details and an example of a counter controlled loop program to calculate asset depreciation over 7 years. The program initializes variables, uses a for loop to decrement the asset value by $4,000 per year and calculate the accumulated depreciation. It outputs the end asset value and total depreciation. Pseudocode, a tracing table and flowchart are provided to explain the program logic.

Uploaded by

Mardiha Ishak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
50% found this document useful (2 votes)
490 views4 pages

CBCP2101 - Computer Programming I

This document contains information about a computer programming course, including the student's details and an example of a counter controlled loop program to calculate asset depreciation over 7 years. The program initializes variables, uses a for loop to decrement the asset value by $4,000 per year and calculate the accumulated depreciation. It outputs the end asset value and total depreciation. Pseudocode, a tracing table and flowchart are provided to explain the program logic.

Uploaded by

Mardiha Ishak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

FACULTY OF SCIENCE AND TECHNOLOGY

SEMESTER 1163

CBCP2101

COMPUTER PROGRAMMING I

MATRICULATION NO : 901107025629001

IDENTITY CARD NO. : 901107025629

TELEPHONE NO. : 011 1075 1814

E-MAIL : [email protected]

LEARNING CENTRE : KEDAH LEARNING CENTRE, ALOR SETAR


Programming technique: Counter controlled loop – Loop with increasing counter control

Input:

1) Year, y ; y >= 1 ; y <= 7

2) Initial value, i = 28000

3) Depreciation value per year = 4000

Output:

1) End of year value, end_value ← i – 4000

2) Accumulated depreciation, accumulated_depreciation ← 4000*y

Pseudocode:

1.0 Start
2.0 Set y = 1 and i = 28000
3.0 For (y = 1 ; (y >= 1 and y <= 7) ; i decrement 4000) start_for
3.1 end_value ← i – 4000
3.2 accumulated_depreciation ← 4000*y
3.3 End_for
4.0 Print end_value and accumulated_depreciation
5.0 End
Tracing table:

y y >= 1 ; y <= end_value ← i – 4000 accumulate_depreciation ← 4000*y


7
1 True 24000 ← (28000 – 4000) 4000 ← (4000*1)
2 True 20000 ← (24000 – 4000) 8000 ← (4000*2)
3 True 16000 ← (20000 – 4000) 12000 ← (4000*3)
4 True 12000 ← (16000 – 4000) 16000 ← (4000*4)
5 True 8000 ← (12000 – 4000) 20000 ← (4000*5)
6 True 4000 ← (8000 – 4000) 24000 ← (4000*6)
7 True 0 ← (4000 – 4000) 28000 ← (4000*7)
8 False 0 28000
Flowchart:
Start

y=1

i = 28000

depreciation = 4000

FALSE
y >= 1 AND y <= 7

TRUE

end_value ← i – 4000

accumulated_depreciation ← 4000*y

Print end_value

Print accumulated_depreciation

End

You might also like