Professional Documents
Culture Documents
Lab Exercise Chapter 1
Lab Exercise Chapter 1
Exercise 1.
Familiarize with the C development environment:
a. MinGW
i. Download the MinGW portable from eLearn and install it on
your PC/Laptop.
ii. Use any text editor (e.g. Notepad) to create a file with
content below and save as helloworld.c in the bin folder of
MinGW that youve installed earlier
iii. Run the command prompt by typing cmd from your windows
iv. Go to the bin folder of MinGW and run command below:
gcc helloworld.c -o helloworld.exe
v. Notice it will create an executable program call
helloworld.exe. You can run the program that youve just
created by typing the program name (e.g. helloworld)
b. Microsoft Visual C++
i. Start the Microsoft Visual C++
ii. Create a new Win32 console empty project
iii. Create a new c program file with the same content as above
and save it as helloworld.c
iv. Run the program by clicking the menu option Debug->Start
without debugging
(Refer to the demo)
Step 1: Go to New->Project
Step 5: Right click the Source files, click Add -> New Item, to add a
new .c file
Step 6: Choose C++ File (.cpp), and type your file a name and end
with .c extension. Then click Add. [IMPORTANT: For c program,
Modify the program as below and run it again. Notice if theres any
difference?
\t
\a
\\
Exercise 3.
Create a simple calculator that can add two integers and
produce the output
Notes to instructor:
1. Demo the usage of different development environment
2. Explain the simple structure of C program
3. Explain the usage of printf and scanf statement