Assignment Topic 1,2,3 New

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

KKKR 2422– Introduction to computer

programming
ASSIGNMENT TOPIC 1, 2 AND 3

QUESTION 1

1. Write a MATLAB coding to display only the final value of c from the information given
below:

• a is a vector from 1 to 5
• b = b + a (c)
• c = c + 1 until it is less or equal to length of a
• Assume b = 0 and c =0.5 initially

QUESTION 2

2. Answer the following questions based on below situation:

“A mixing tank is used to blend two materials X and Y to obtain new material Z. Material
X must be less than 40 litre while material Y can be any value. If material X is bigger,
display the ratio of X to Y. If material X is equal to Y add both materials. Otherwise,
display that the amount is unknown, tank may overflow.”

(i) State the task to be accomplished by the given problems.

(ii) Develop an algorithm for achieving the task stated in question 2(i).

(iii) Develop a flowchart from the algorithm developed in question 2(ii).

(iv) Develop a MATLAB program based on the algorithm and flowchart in question
2(i) and 2(ii).

You might also like