Exercise Sequential Control Structure
Exercise Sequential Control Structure
CSC415
QUESTION 1
1) prod_a 6) average
2) c1234 7) 12345
3) while 8) finGrad
4) sum.of 9) grade1
5) $total 10) new bal
b. Give the most appropriate data type for each of the following values:
i. 23 v. 20125.12345
ii. ‘c’ vi. true
iii. 8.52 vii. 40000
iv. “9374”
c. Create a variable name for each of the following and give the appropriate data type:
i. Speed of an automobile
ii. Shipping rate per ringgit
iii. Highest score in exam
iv. Initial ‘m’ for male or ‘f’ for female
v. Amount of students in a class
vi. Pass or fail
QUESTION 2
I. z = [a2 + 4ac] ÷ 2
III. b2 – 4ac
II. y = √a(b+c)(b-c)
2
*Prompt the user to enter the appropriate input and display the value of z and y. Use pow() and
sqrt() functions in your formula if necessary.
b. Write down the value of num after each of the following statements. Assume that the value of num is
100 before each statement executed :-
i) num++
ii) num *= 3
iii) num += 10
iv) num -= 100
c. Find and explain the errors if any for the following expression :-
i) 35.0 = num1 + num2
ii) second = first ++ second;
iii) num1 + 3 = num2 + 7
iv) sum += 5;