Docsity

Programming - Second mid-term exam December 2017 with solutions, Exámenes de Programación Informática

Toggle sidebar
bg1
Programming
Bachelor in Aerospace Engineering
First mid-term exam. Dec 04th 2017
Please return this sheet with your resolutions, and any other sheet for draft or notes, thanks!
SURNAME, NAME:
NIU/NIA: 100
INSTRUCTIONS
• Do not separate these sheets.
• Read carefully these instructions.
• Write your name in capital letters in every sheet (test, exercises, resolutions, and notes)
involved with the exam.
• After the time for the test, the sheet for the test return the test sheets (you can keep your
note for the test till the end of the exam).
• If you finish earlier the test, raise your hand, give back your test and ask for the
exercises.
• If you finish earlier the exercises, raise your hand and wait the instructions from a
teacher.
• At the end of the exam YOU MUST GIVE BACK ALL THE SHEETS (blank,
exercises, your resolutions, your draft and notes).
• Test: mark your answers at the Test statements sheets only.
• Exercises: start each new exercise in a new different sheet.
pf3
pf4
pf5

Vista previa parcial del texto

¡Descarga Programming - Second mid-term exam December 2017 with solutions y más Exámenes en PDF de Programación Informática solo en Docsity!

Programming Bachelor in Aerospace Engineering First mid-term exam. Dec 04 th^2017 Please return this sheet with your resolutions, and any other sheet for draft or notes, thanks! SURNAME, NAME: NIU/NIA: 100

INSTRUCTIONS

  • Do not separate these sheets.
  • Read carefully these instructions.
  • Write your name in capital letters in every sheet (test, exercises, resolutions, and notes) involved with the exam.
  • After the time for the test, the sheet for the test return the test sheets (you can keep your note for the test till the end of the exam).
  • If you finish earlier the test, raise your hand, give back your test and ask for the exercises.
  • If you finish earlier the exercises, raise your hand and wait the instructions from a teacher.
  • At the end of the exam YOU MUST GIVE BACK ALL THE SHEETS (blank, exercises, your resolutions, your draft and notes).
  • Test: mark your answers at the Test statements sheets only.
  • Exercises: start each new exercise in a new different sheet.

TEST ( 2 .5 points)- 25 minutes

The test consists of 10 multiple-choice questions. Each question has only one right answer. Right answer gets +0. 25 points. Wrong answers get - (0. 25 /3) points; no answer gets 0 points. Mark your answers in this sheet.

  1. Which are the required values for the variables a, b and c to make the next logical expression false. ~( a && b~=0 ) || c > 1 a. a = 0 , b = 0 and c = 1; b. a = 1 , b = 0 and c = 2; c. a = 1 , b = 0 and c = 1; d. a = 1 , b = 1 and c = 1;
  2. For matrices, the pre-allocation is: a. The dynamic assignation of memory space for storing matrix element while the program is executing. b. The declaration of any kind of matrix with a predefined number of elements. c. The feature of Matlab® which allows to increase the size of any kind of matrix dynamically. d. The positioning in a specific matrix element.
  3. Select the right assertion about recursive functions. A recursive function is ... a. ... a function whose body consists of just a simple expression defining a base case. b. ... the base method to broke down a modular program into modules. c. ... a function whose functionality is defined in terms of itself. d. ... a function which includes several functions calls, one inside of another.
  4. Which one of the function headers below is compatible with the following function call? a = test([ a , b],2) a. function test( x , y , size ) b. function x = test( x , y , size) c. function test( y , size) d. function x = test( y , size)
  5. Which one of the following assertions about modular programming is false? a. It is based on decomposing the solution of the main problem into smaller solutions b. It forces the main script to implement only basic operations c. It is based on the implementation of modules or subprograms, which can be even reused by different programs d. It produces programs that are more readable and easier to deal with.
  1. What does control structure represent the following flow diagram? a. If-else b. Loop c. If-elseif-else d. Nested loops
  2. Which sorting algorithm is the one for the following source code function list = sortAlgX( list, lengthList ) for j = 1:(lengthList - 1) indexMin = j; for i = (j + 1): lengthList if list(i) < list(indexMin) indexMin = i; end end if (indexMin ~= j ) tmp = list(indexMin); list(indexMin) = list(j); list(j) = tmp; end end end a. naïve buble b. smart buble c. selection d. insertion

Programming Bachelor in Aerospace Engineering First mid-term exam. Dec 04 th^2017

INSTRUCTIONS

  • Do not separate these sheets.
  • Read carefully these instructions.
  • Write your name in capital letters in every sheet (test, exercises, resolutions, and notes) involved with the exam.
  • After the time for the test, the sheet for the test return the test sheets (you can keep your note for the test till the end of the exam).
  • If you finish earlier the test, raise your hand, give back your test and ask for the exercises.
  • If you finish earlier the exercises, raise your hand and wait the instructions from a teacher.
  • At the end of the exam YOU MUST GIVE BACK ALL THE SHEETS (blank, exercises, your resolutions, your draft and notes).
  • Test: mark your answers at the Test statements sheets.
  • Exercises: start each exercise in a new different sheet.

Programming Bachelor in Aerospace Engineering First mid-term exam. Dec 04 th^2017

Exercise 2 (4. 0 points)

Design and write a program in Matlab® to manage the Moto GP World Championship results. A maximum of 23 riders grouped at most in 6 different teams fights for the championship. A rider ranking is elaborated when the championship is finished, and the winner is designed based on the score obtained during the different races. To write the code for your program, please follow these next steps:

  1. Define and declare the data structures that needed to keep the information for the riders enrolled in the World Championship. The following data must be kept for each rider: o Name: one string/array of char for both rider name and surname. o Number: number in the bike o Team: bike team for the rider. You can assume that there is a pre-defined vector with all the different possible teams: teams = [ "Aprilia" , "Ducati" , "Honda" , ... "KTM" , "Suzuki" , "Yamaha" ]; o Score: total points obtained by the rider in the championship.
  2. Write a function called addRiders to manage the subscription for all the riders who are going to participate in the World Championship. Once a rider has been enrolled, the program must ask for the user if he/she wants to include any other. The program must control that no more than 23 riders can be enrolled. The function must return the data structure for the whole participants enrolled and the number of participants. The following premises must be considered before to enroll a new rider in the championship: o When you are trying to enroll a new rider, you must validate that this rider hasn´t be enrolled before. For that, you must assure that there is no rider enrolled with the same number than the new one (define and use a function for this). Otherwise, you must ask for another number and try again. o To facilitate the introduction of the team, you must ask for the user an integer number that the program will convert to the corresponding name of the team related to the position in the pre-defined teams vector. o The score will be set to 0 when a new rider will be added. o Once a rider is already enrolled, the program must show on the screen all the information for this rider (define and use a function for this)
  3. Write, using the functions indicated above , the main program that purposes only the following: o Define and Pre-allocate the needed variables and data structures o Ask for the user the information to enrol the riders to the World Championship o Show on the screen the total number of riders enrolled.