0% found this document useful (0 votes)
128 views

Practical Task 1 (4 Hours) Basic Programming

This document provides instructions for a practical C programming task involving input/output functions. Students are asked to write a program that takes a staff name and ID as input using scanf, and displays a greeting along with the inputted name and ID using printf. The program output is given as an example. Students must produce an IPO chart, pseudocode, flowchart and source code to meet the requirements. The document also gives examples of simple C programs using scanf, printf, and other basic concepts like data types, variables, and syntax errors.

Uploaded by

Ariyanna EduTv
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
0% found this document useful (0 votes)
128 views

Practical Task 1 (4 Hours) Basic Programming

This document provides instructions for a practical C programming task involving input/output functions. Students are asked to write a program that takes a staff name and ID as input using scanf, and displays a greeting along with the inputted name and ID using printf. The program output is given as an example. Students must produce an IPO chart, pseudocode, flowchart and source code to meet the requirements. The document also gives examples of simple C programs using scanf, printf, and other basic concepts like data types, variables, and syntax errors.

Uploaded by

Ariyanna EduTv
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/ 7

DJM 20032– C PROGRAMMING PRACTICAL TASK 1

[Pick the date]


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.

PRACTICAL TASK 1: Scanf And Printf Function 1


DJM 20032– C PROGRAMMING PRACTICAL TASK 1
[Pick the date]
How to use CODE BLOCK

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.

PART A (LECTURER GUIDE)

PRACTICAL TASK 1: Scanf And Printf Function 2


DJM 20032– C PROGRAMMING PRACTICAL TASK 1
[Pick the date]
Construct, Compile and Execute a simple C program.

Example 1 - Basic Code

1. Write simple program below in the text editor.

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.

5. Show your work and discuss with your lecturer.

Example 2 - Basic Code

PRACTICAL TASK 1: Scanf And Printf Function 3


DJM 20032– C PROGRAMMING PRACTICAL TASK 1
[Pick the date]
1. By using the same program at example 1, add 3 lines codes like below and run the program.

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.

Example 3 – Basic code

1.By using the example 2, try to remove all the \ n and build and run the program.

2. Observe the output and discuss it with lecturer.

Example 4 – Syntax error

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.

Use input and output statements in simple C program.

Example 5 – Data Types & Variables

1.Write down the program below and try to build the program.

3. Identify the output and discuss with lecturer.

Example 6 – Testing scanf and gets

1.Write down the program below and try to build the program.

PRACTICAL TASK 1: Scanf And Printf Function 5


DJM 20032– C PROGRAMMING PRACTICAL TASK 1
[Pick the date]

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.

4. To solve it, replace

5.Run again the program by inserting full name. Observe and try to compare scanf versus gets for string.

PRACTICAL 1: Scanf and Printf Function

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.

*************Welcome to Mydin Store Staff System****************

*******************Please Insert Your Name**********************

Please Enter Your Name Here : Lukman Bin Hakim

Please Enter Your ID Staff No : 45123

***********************Greetings*******************************

Lukman Bin Hakim

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.

Prepared by: Approved by:

............................................................... .............................................................
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

PRACTICAL TASK 1: Scanf And Printf Function 7

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy