CS2503 Exam Exercises

1.  Bit

2.  Nibble

3.  Byte

4.  Mega, giga, tera, peta.

5.  What is the difference between 1 MB and 1 Mb?

6.  What is the exact whole number represented by1 KiB? Include the units.

7.  Given these matrices,

·  Which sums of the above matrices are defined?

·  Which products of the above matrices are defined?

·  Let T denote transpose. Calculate the following:

8.  Write the system of equations in matrix form, :

x + 3y = 22

x + 2y – z = 9

2x – y + z = 7

What is the augmented matrix for the above system of equations?

9.  Write the system of equations given the augmented matrix:

10.  Let T represent the transpose operator. Consider the following: , If matrix A is n by m and matrix B is m by k, show that C and D are both the same size.

11.  Let x and y be n-length vectors of collected data. Vector x is the independent variable and vector y is the dependent variable. If there is a linear relationship between x and y, the value called the correlation coefficient will be close to Using Matlab statements, compute the correlation coefficient given the equation shown here:

12.  Show two ways using Matlab to make a same length vector that starts at 0, ends at p and increments by p/6. Use linspace and the vector notation: [start:increment:end]

13.  Let A and B be two square matrices of equal dimension. Explain the difference between A.*B and A*B.

14.  Let A, B, C, and D be matrices defined by Matlab with real numbers. What must be true about the dimensions of the matrices if C=A*B and D=A .* B?

15.  What is computer software?

16.  What is a compiler?

17.  What is an operating system?

18.  What is an algorithm?

19.  What are two common programming paradigms?

20.  What is the difference between syntax and logic errors?

21.  What is computer programming?

22.  If matrix B = [ 1, 0 , 2 ; 0, 1, 3 ; 1, 1, 9 ]. What are the following:

a.  B( 2:3, : )

b.  B( 1:2, 2:3 )

c.  B( : , 2:3 )

23.  Calculate how many items are in this array: C=[ 0 : .01 : 1 ];. Now show how to create the same vector using the linspace function.

24.  Describe two types of programming design tools.

25.  Define pseudo-code

26.  What is the basic set of flow chart symbols?

27.  What are the four common parts of any programming language?

28.  What is software engineering?

29.  What is the software life-cycle?

30.  Write a script to compute the volume of a sphere. Your script should have a comment header and prompt the user for the input radius. Display the volume.

31.  Write a function that accepts three input parameters: length, width, and height of a box. Return the volume and surface area.

32.  *What are the rules for writing a function that are different from writing a script?

33.  *Explain the different behavior of variables in a script compared to a function.

34.  Write a function that will compute and return the both surface area and volume of a sphere. The function will require one input: the radius.

a.  Repeat for a cube.

b.  Repeat for a cylinder knowing the height and radius. Include the top and bottom for the surface area.

35.  What is the syntax for an anonymous function? Give a working example of an anonymous function.

36.  Write a script that computes and displays the total resistance for a group of resistors arranged in parallel according to the formula: , Where is the total resistance of the parallel system, and is the resistance of each individual resistor in the parallel system

37.  Write a function named sumRatio that accepts two input parameters: 1) r, between 0 and 1; and 2) n, a natural counting number. Compute and return the sum:

(continued on the next page)

  1. Formatting with fprintf.
  2. Syntax for fprintf.
  3. Escape character for formatting output.
  4. Right and left justify.
  5. Field size.
  6. Precision specifier.
  7. Conversion characters.
  8. Write an fprinf statement to print a string in variable x, right justified from the 25th column on a page.
  9. Write an fprintf statement to print the value in scientific notation left justified with two digits to the right of the decimal.
  10. Show what is printed in each column of a page with:

fprintf( ‘%10s\n%10.3f\n%-10.2E\n’, ‘Matlab’, 3.14, 6.02e23 );

fprintf( ‘%5.1f%5.1f’, 2.1, 3.2 );

  1. Show how to display all the values in a vector named prices, left justify in a field of 12 with two digits to the right of the decimal. Include a $-symbol to the left of each output value.