Lab 21
Lab 21
Direction: Complete the practical works. Consult with your lecturer for any
problem encountered.
OBJECTIVES :
EQUIPMENTS :
Procedures:
// This is the first program that just writes out a simple message
2.1.6 Write the above program and save it as Practical11. To compile, click on
Execute and choose Compile. Alternatively the program can be compiled by
using Ctrl + F9 hotkey.
2.1.7 Run the program and capture the codes, Compile progress and output.
To Run, simply click on Execute > Run. Alternatively hit the Ctrl + F10.
Procedures:
2.2.1 By applying the steps involved in Lab 2.1 till 2.2, solve the following task.
2.2.2 Write your codes by using Dev-C++ software and check for any errors.
2.2.3 Rewrite your codes in the spaces provided.
Answer:
Write a program that will display your name and registration number in a new
line. Use escape sequence character in your command.
Answer:
Write a program that will display the following output by using escape
sequence characters (\n, \t, \”) in your program.
Hello World!
My course name is:
“DEC20012 Programming Fundamentals”
Answer:
Write a program by only using the printf() function to produce the following
picture on your screen. Use escape sequence character in your program.
+--^----------,--------,-----,--------^-,
| ||||||||| `--------' | O
`+---------------------------^----------|
`\_,---------,---------,--------------'
/ XXXXXX /'| /'
/ XXXXXX / `\ /'
/ XXXXXX /`-------'
/ XXXXXX /
/ XXXXXX /
(________( `------'
Answer:
Write the following program. Observe how scanf() function are used to get
input
Answer:
[80 Marks]
5 PSIS / JKE / DEC20012 – PROGRAMMING FUNDAMENTALS / PRACTICAL WORK 2
CLO 2P
Questions
Output:
2. Fill in the blank with the expected output for the following program. (4 marks)
#include <stdio.h>
int main()
{ char c =
‘A’;
char name[20] =
“C_Programming”; float f = 1.2;
int num = 15;
printf(“Character is %c \n”, c);
printf(“Name is %s \n” , name);
printf(“Float value is %.1f \n”, f);
printf(“Integer value is %d\n” , num);
Getchar(); return 0;
}
Output:
Character is _______A_______
Output