Practical Task 1 (4 Hours) Basic Programming
Practical Task 1 (4 Hours) Basic Programming
CLO2 : Constructs a high level programming language in solving variety engineering and scientific problems
PLO3 : Design / development of solution: design solutions for well-defined technical problems and assist with
the design of systems, components or processes to meet specified needs with appropriate consideration
for public health and safety, cultural, societal, and environmental considerations (DK5)
: Guided Response: The early stage in learning a complex skill that includes imitation and trial and error.
P3
Adequacy of performances achieved by practicing.
1. AIM
i. To constructs a high level programming language in solving variety engineering and scientific
problems
2. OBJECTIVES
At the end of the session, the student will be able to;
i. Identify the high level programming language
ii. Construct a simple C program
iii. Compile and execute programs
3. EQUIPMENTS/MATERIALS
i. Computer with Code Blocks (Open Source Cross Platform IDE)
4. THEORY
Code::Blocks is a free C/C++ and Fortran IDE built to meet the most demanding needs of its users. It is
designed to be very extensible and fully configurable.
C PROGRAMMING course introduces program design and development. Student will learn to design,
code, debug, test and document well-structured programs based on technical and engineering problem.
1. Click icon Create new project and choose Console Application from the template menu
2. Click Go and Next button and choose C language for application. Click Next button.
3. Type project title and select the browser to choose directory project will be saved. Example D:\ DJM
20032\Ahmad. Do not save in the C: directory.
4. Click next and do not change the default setting in the compiler configuration. Click Finish.
5. CODE BLOCK will produce default structure of C program as shown in the picture.
2 . Click the first icon (build) in the debug section and watch the output from the Log.
4. Click the second button (Run) in the debug section and watch the black window appear on the
screen.
2. Note that 3 lines of sentences will appear at the output screen. Each of the sentences will have new
paragraph. Note at the end of each statements there is syntax like below.
1.By using the example 2, try to remove all the \ n and build and run the program.
1.Write down the program below and try to build the program. Note that the Log section will show
incomplete process of build because of syntax error.
2. Observe the Logs, try to figure how many errors and warning for program above.
3. Scroll the Logs upwards and read the possible error and warning.
PRACTICAL TASK 1: Scanf And Printf Function 4
DJM 20032– C PROGRAMMING PRACTICAL TASK 1
[Pick the date]
4. To allocate the syntax error, double click the error and the Code Block will redirect or point indirectly or
directly to error.
5. Use the previous example to guide and find the syntax error. A good programmer tries to solve an error
one by one. Try build program upon each solved error.
1.Write down the program below and try to build the program.
1.Write down the program below and try to build the program.
2. Fill the name by using short name for example “ali” then fill the age as required. Observe the output.
3. Run again the program, then fill the name with full name for example “ ali bin ahmad”. Observe the
output. Discuss with your lecturer.
5.Run again the program by inserting full name. Observe and try to compare scanf versus gets for string.
Condition : Figure 1 shows an output on screen of a C program that is written for Mydin
PRACTICAL TASK 1: Scanf And Printf Function 6
DJM 20032– C PROGRAMMING PRACTICAL TASK 1
[Pick the date]
Store Staff System which need a staff to key in his name and staff id using
appropriate scanf and printf function. The name and no id will be entered using
scanf function. A correct the data types must be use in this program. Assume
that the string does have contain any whitespace characters.
***********************Greetings*******************************
ID:45123
***************************************************************
Figure 1: C program output on screen
Based on the requirement and output, write the Input Process Output (IPO) Chart, Pseudocode, Flowchart,
and source code by using C language.
............................................................... .............................................................
JULIYANNA BINTI ALIMAN GADAFFI BIN OMAR
Lecturer Head of Diploma of Mechatronic Engineering
Mechanical Engineering Department Mechanical Engineering Department
Politeknik Merlimau Melaka Politeknik Merlimau Melaka