Академический Документы
Профессиональный Документы
Культура Документы
Prepared By:
Ts. Dr. Nafrizuan Mat Yahya
nafrizuanmy@ump.edu.my
h/p: 0186652051 office: 09-424 5930
Assignment Objectives:
Use and construct various variable types and constant declarations for all sizes of
numeric data and strings.
Construct and analyze a simple C program that can input data using scanf( )functions
and related escape sequences.
Date: ____________________
Student
Group Members Section
ID
/60
// In the name of *ALLAH/ GOD, we declare that this is our original work.
For every each assignment, you need to start your program with the following form:
// Put all the members of the group name (ID no./ Section)
// Date of assignment
// Put your assignment number
// Put your question number
Example:
3) To print data left justified, you would use a________in the conversion specification.
(a) flag
(b) precision
(c) size
(d) width
(e) width and precision
4) Which of the following is not a character constant in C? (answer may more than one)
(a) ‘ C ’
(b) ‘ bb ’
(c) “ C ”
(d) ‘ ? ’
(e) ‘ ’
5) Which of the following is not an integer constant in C? (answer may more than one)
(a) -320
(b) +45
(c) -31.80
(d) 1456
(e) 2,456
6) Which of the following is not a floating-point constant in C? (answer may more than
one)
a) 45.6
b) -14.05
c) ‘ a ’
d) pi
e) 40
6
2.0 What is the type of each of the following constants?
2.1 15 = ________________________
2.2 -14.05 = ________________________
2.3 ‘b’ = ________________________
2.4 “1” = ________________________
2.5 “16” = ________________________
2.6 “7” = ________________________
2.7 3 = ________________________
2.8 “3.14159” = ________________________
2.9 ‘2’ = ________________________
2.10 5.1 = ________________________
2.11 “Hello” = ________________________
2.12 15L = ________________________
2.13 8.5L = ________________________
2.14 8.5f = ________________________
2.15 ‘\a’ = ________________________
15
6
BFF2003 Computer Programming Assignment 4 18/19
Page 4
4.0 Write a statement to print the following line. Assume the total value is contained in a
variable name cost. (Please print the program and the output screen)
5.0 You are assigned to develop an inventory report of your manufacturing company. To give
your material control manager an idea of what a proposed report might look like, you have
to write a small program to print a sample. The specifications for the report are shown in
figure below. (Please print the program and the output screen)
12
6.0 Write a program that uses defined constants for the vowels in the alphabet and memory
constants for the even decimal digits (0, 2, 4, 6, 8). It then prints the following three lines
using literal constant for the odd digits. (Please print the program and the output
screen)
14
BFF2003 Computer Programming Assignment 4 18/19