Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Daspro Practice | Micky

Practice Module 2
Introduction to Programming
NIM/Name : ……………………………..
The objective of this module is student have capability to :
1. Describe how a program code could be a runable program on a computer device
2. Recognize the programming work environment
3. Identify parts of a program code and their uses
4. Translating the algorithm notation into C language code
5. Compile and run simple program code
6. Find program code errors and improve them

Problem 1: Introduction to the Programming Environment


Our subjects use DevC ++ software as a program development environment. First of all, we need to
know the main the features of DevC ++ to build simple program code.

Open the DevC ++ program, then create a new file by clicking File> New> Source File, or clicking the
shortcut. In the file editor, type the simple code as shown in figure 1.

Figure 1. Simple code

Create a new folder in your own data drive and give a name according to your NIM. Save the file in
your new folder by clicking File> Save and choose the folder you just created. Give the file name

1
Daspro Practice | Micky

1_myfirstprogram.c. and in the option "save as type" select the C source files (* .c) as shown in the
figure 2.

Figure 2. Save the simple program file

Through Windows Explorer, try to check the folder that you have created. State the name of the file
in the folder.

Compile the program by clicking Execute> Compile, or shortcut. Notice what happened next, is there
any error occur?

If no error, run the program by clicking Execute> Run, or shortcut.

Show the result of your program (use the snipping tool to capture image) and describe it.

2
Daspro Practice | Micky

Reopen the folder that you created earlier. Notice what files are there now, any changed? Give your
conclusion?

Problem 2: Translating Pseudocode into C Language


We will create new simple program code in the same folder. First, learn the pseudocode below.

Area_of_Rectangle Program
{Calculate the area of a rectangle by entering the length and width}

Declaration
length, width, area: integer

Algorithm
input (length)
input (width)
area  length * width
output (area)

The pseudocode will be translated to C language use the following guide:

Group Algorithmic C language


Fundamental Type integer int
real float
double
char char
Comment {comment} /* comment */
Display output printf
Reading input scanf
Value filling  =

3
Daspro Practice | Micky

Save the code with file name 2_area_of_rectangle.c, then compile and run. Show the result of the
program (use the snipping tool to capture image) and describe it.

Problem 3: Translating Flowchart into C Language


Known that the algorithm of calculates the area of square using flowchart as shown in figure 3.

start

input
side

area  side * side

output
area

end

Figure 3. Flowchart the area of square

4
Daspro Practice | Micky

In the similar way, the flowchart can be translated into C language as following code.

Save the code with file name 3_area_of_square.c, then compile and run. Show the result of the
program (use the snipping tool to capture image) and describe it.

Problem 4: Calculates the Final Math Score of Student


The teacher of mathematics subject has three categories to determine the final score to his student.
First is score of assignment, then evaluation score and score of soft skill with percentage 30%, 45%
and 25% in sequence.
Create a simple program for helping the teacher to get the final score for his student. Calculate
percentage of each category and sum them up. Save the program with name 4_final_math_score.c.
What are the input and output for this program? What process needed to get the final score from
each category?

Write the algorithm (any notation you choose) here.

Copy the text of your code here.

5
Daspro Practice | Micky

Show the result of the program (use the snipping tool to capture image) and describe it.

Conclusion
What do you learn from this practicum? Describe the conclusions that you obtained!

Submission:
Save the report with name P02_NIM.docx and your program files in folder named P02_NIM, upload your
work in zip file to http://learning-if.polibatam.ac.id.

You might also like