Вы находитесь на странице: 1из 4

Page 1

Faculty of Manufacturing Engineering


“In the name of Allah, The Most Beneficent, The Most Merciful”

BFF/BHM 2003: COMPUTER PROGRAMMING

ASSIGNMENT #4 : INTRODUCTION TO THE C LANGUAGE

Prepared By:
Ts. Dr. Nafrizuan Mat Yahya
nafrizuanmy@ump.edu.my
h/p: 0186652051 office: 09-424 5930

Due Date: (Monday) 08 October 2018 (before 5pm).

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.

There are six (6) questions. Please answer all questions.

Date: ____________________

Student
Group Members Section
ID

/60
// In the name of *ALLAH/ GOD, we declare that this is our original work.

BFF2003 Computer Programming Assignment 4 18/19


Page 2

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:

// Micheal Jackson (FA122/F09), Makcik Tipah (FA325/F08), Abang Mawi (FA032/F07)


// 11 Mei 2009
// Assignment #1
// Question 12.

Put your coding and necessary comments here

1.0 Please circle a correct answer for each questions below.

1) Which of the following statements about a constant is true?


(a) Character constants are coded using double quotes ( “ ).
(b) It is impossible to tell the computer that a constant should be a float or a double
float.
(c) Like variables, constant have a type and may be named
(d) Only integer values can be used in a constant
(e) The values of a constant may be changed during a program’s execution.

2) The ____________ conversion specification is used to read or write a short integer.


(a) %c
(b) %d
(c) %f
(d) %hd
(e) %lf

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) ‘ ’

BFF2003 Computer Programming Assignment 4 18/19


Page 3

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

3.0 Code the variable declaration for each of the following:


3.1 a character variable named option =________________
3.2 an integer variable, sum, intialized to 0 =________________
3.3 a floating-point variable, product, initialized to 1 =________________
3.4 a short integer variable named code =________________
3.5 a constant named salesTax initialized to 0.0825 =________________
3.6 a floating-point name sum of size double initialized to 0 =________________

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

Вам также может понравиться