You are on page 1of 4

School of Engineering

E116 – Computer Programming

Exercise for Problem 01: Data Types

1. Determine which of the following are invalid variable names:

(a) 2015class (b) classof2015 (c) class_2015


(d) $class$2015 (e) page1of2 (f) main_class
(h) char

2. Write a declaration statement to declare each of the following variables:

(a) The variable count is to be used to store an integer.


(b) The variable height is to be used to store a decimal number.
(c) The variable initial is to be used to store a character.

3. Suggest suitable data type and variable name to represent each of the following:

(a) Population of Singapore [5,260,000]


(b) Gender [M or F]
(c) Circumference of circle
(d) Body temperature (in degree C)
(e) Number of students in a class

4. Write the complete C program to print “Let’s keep our campus clean and green!”

5. Using only one printf() statement, write the C codes to print the following output.
School of Engineering

6. Examine the code shown below. What would be the output produce by the 5
printf() statements?

Supplementary information: The complete ASCII character set is shown in table below.
School of Engineering

7. Identify the errors in the C program shown below:


School of Engineering

8. Examine the C codes below and determine the output of the program?

--- END ---

You might also like