CP 111 Tutorial Questions 3
CP 111 Tutorial Questions 3
TUTORIAL QUESTIONS
Question One
With example (s) briefly discuss on the following concepts as used in programming languages
a) Data type
b) Variable
c) Identifiers
d) Constant
e) Assignment and assignment operator
f) Variable declaration
Question Two
a) You need an application that will store your names i.e. Juma Ally, Gender i.e. F or M,
GPA i.e. 3.5 and marital status such as Single, Married etc. By applying rules for defining
variables in programming, suggest the appropriate variables and their associated data
types (Note, each variable and its associated data type should appear in one line).
b) Given the following equation
a = b + c + d whereby
b= 20.5, c = 0.1, d = 10
i). Based on the given equation and values of the variables suggest the appropriate data
types for each variable in the equation
ii). Assume a is declared as integer i.e. int a. suggest the value of a after execution of the
above equation
iii). What will happen when a is declared as char?
iv). T/F in programming this equation in b) indicates that the value of the sum of b + c +
d will be assigned to a
v). T/F in programming this equation in b) indicates that the value of the sum of b + c + d
will be compared to a
vi). Represent the above equation variables and their values using RAM Diagram (block)
and explain what is happening in RAM.
vii). What is the difference between a = b + c + d and a = = (b + c + d) in programming?
Question Three
Mr. Gratian has a shop located at 77 in Dodoma region, dealing with buying and selling
sunflower oil. Mr. Gratian wants program that will record number of items in terms of liters
bought and sold per year. The program should also, accept the buying and selling prices for each
liter. For each category the program should also calculate the total purchase and selling amount
per year. Lastly, the program should determine the profit earned (if any) showing the