Question 1 (b) Briefly describe what a type is in the context of a programming l
ID: 3914311 • Letter: Q
Question
Question 1 (b) Briefly describe what a type is in the context of a programming lan- guage. Give an example of a MATLAB type [2 marks] (c) In most programming languages, text is encoded as a list of ASCII characters. If the letter A' is mapped into the decimal number 65, what are the values used to represent the word 'IPE? [4 marks] (d) List and briefly describe two broad approaches the construction of large software applications. 4 marks] Question 2 (c) The file f1.m contains the following code function z f1(x,y) end After you run the commands below, what will be the value of “a"? Explain your answer. > > x=1 ; y-3, 2-2; y fl(z,x); >>a=(x, y, z); 4 marks] (d) Write a MATLAB function, called surface.area that takes the length of the sides of a cube as a parameter and returns the surface area of that cube 4 marks] Question 3 (c) Given a cell-array C with size 2 x 3, which of the following commands initialises the bottom right corner element of C to 10? B. C(end 10; C. C end+1[10]; D. C[end][10; [3 marks] (d) Given the two string variables A and B, write down a logical state- ment in MATLAB to produce the specified boolean result for each of the three cases below. As an example of an expected answer, the logical statement: corresponds to the MATLAB code: True if A is NOT empty; false otherwise length(A)0 The three cases are: i. True if A and B are identical ignoring case; false otherwise [2 marks] ii. True if the letters in both A and B are all in upper case; false otherwise. [3 marks] ii. True if the length of either A or B is even, false otherwise [3 marks]Explanation / Answer
Ans1)
(b) Type or data type is a classification of data that tells the compiler or interpreter how the programmer intends to use the data.Example of data types in MATLAB are integers, character, Boolean etc.
(c) The values used to represent the word "IPE" are 73 , 80 and 69 which are basically ASCII codes of I,P and E respectively.
(d) The two approaches are object oriented and functional programming.
Object oriented programming- It is a programming paradigm based on the concepts of "objects" which may contain data, in the form of fields which are generally called the attributes and code in the form of procedures generally called methods.
Functional Programming- It is a programming paradigm that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.