Table of Contents: Lab 1: Getting Started 2 1.1 B 2 1.2 F H W !' 5 1.3 G E 7
Table of Contents: Lab 1: Getting Started 2 1.1 B 2 1.2 F H W !' 5 1.3 G E 7
of Contents
Lab 1: Getting started
At the end of this lab, please upload the following codes in KALAM:
Step 2: You will see this screen pop out
Step 3: Open a new file (File -> New). A blank file will appear
Step 4: An empty file will pop out as below
Step 5: Save the file as *.c (example: program1.c or example1.c): File -> Save As -> program1.c
Step 7: You will see the filename you have previously saved at the top left corner (see below)
Step 8: When writing any code, you MUST start by writing the following 4 lines:
Note that the content of your code will be written in the red box (see below):
Step 9: Commenting is a good practice in programming.
Step 1: To use the printf() function, type out as seen below in Line 7:
Step 2: To print out Hello World!, simply append to the printf() function by typing out “Hello World!”
as below (see Line 7):
Step 3: Run the code to see the output
1. To Run
Editing
Pane
2. Output
Output
Pane
In short, whatever that is written between “…” in the printf() function in the editing pane:
Text output
Step 4: Note that the output comes out in a single sentence ‘Hello World!>Exit code: 0’.
To push the words ‘>Exit code: 0’ to a new line (the equivalent of an ‘Enter’ when typing in a
word document), add ‘\n’ before the closing ” in the printf() function as follows:
Add \n for new line
Upon running the code, the following will be printed out in the output pane:
new line
1.3 Guided Exercises
1.3.1 Printing out your name
For this exercise, write a code that prints out your name and save the code as lab1ex1.c
Instructions:
1. Open a new *.c file and call it lab1ex1.c: follow instructions in Section 1.1 Steps 3-7
2. Type out the basic code: follow instructions in Section 1.1 Step 8-9
3. Tell the code to print your name: see (1. Edit text to print) in figure below
4. To run the code: see (2. Run the code) in figure below
For example, if your name is Ali Yusuf bin Muhammad then you want to print the output “My name
is Ali Yusuf bin Muhammad!” like the following:
3. Output
5. Now include your hobby (see figure below)
6. Run the code
Write a tic-tac-toe program and call it labex2.c that looks like the following:
You may also edit the code to put circles and crosses:
1.4 Assignment 1: Printing your initials
Print out your initials and upload the code as Assignment1a.c
For example,
1. Open your KALAM account and access the subject page: BMM1312
2. Under Week 1, you will see a submission link like below: