You are on page 1of 2

CP 111: PRINCIPLES OF PROGRAMMING

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

Based on the given information determine:-

a) The variables associated with defined problem


b) For each variable in a) suggest the appropriate data types
c) Declare (in one line) the variable defined in a) using data types suggested in b)
d) Define the processes involved in this application
e) What variable values will be stored, displayed (printed) and inputted into and from a
program?
f) For each input variables, suggest the appropriated value and work through processes
defined in d) to determine the final values

You might also like