C0MP1911 Final Exam 1337 Computing 1
|
|
- Elijah Palmer
- 5 years ago
- Views:
Transcription
1 Family Name: Other Names: Signature: Student Number: This PAPER is NOT to be retained by the STUDENT The University Of New South Wales C0MP1911 Final Exam 1337 Computing 1 July 2006 Time allowed: 3 hrs Total number of questions: 22 Total number of marks: 105 You are permitted one A4 sheet of information. You must hand in this entire exam paper, your information sheet, and the answer booklets. otherwise you will get zero marks for the exam and a possible charge of academic misconduct. Ensure that you fill in all of the details on the front of the info sheet, this pink paper, and the 3 answer booklets, and then SIGN everything. Mark one booklet PART C, one PART D, and one WORKING ONLY. The working only booklet will not be marked. Do not use red pen or pencil in this exam. Unless advised otherwise you may not use any language features or library functions not covered in class. Answers which do not comply with the course style guide or which introduce potential security vulnerabilities will be penalised. There are two marks for following the examination instructions. Examiners Use Only Inst A C D Total
2 Part A: Multiple Choice Questions Answer the questions in this part by circling the correct answer. For each correct answer you earn 3 marks. There is no penalty for incorrect answers. Question 1 Which of the following would be the best name for a function to compute the area of a triangle, defined in a file called Triangle.c entirely devoted to calculating the properties of triangles? The function is not an interface function. [A] [B] [C] [D] [E] t area trngle triangle calculatetheareaofatriangle Question 2 On my machine one of these C types is an integer type which can can store more numbers than the other integer types listed. Which one? [A] [B] [C] [D] [E] double long int void char Question 3 Which C expression below is equivalent to this C expression:!(x y) [A] [B] [C] (!x) (!y) (!x) && (!y) x y [D]!( x!= y) [E]!( x == y)
3 Question 4 Consider the following C variable definition: char s[] = "hello world"; Suppose we wish to make a copy of the string in s and have it referred to by the variable p. Which of the following C code fragments does this correctly? [A] [B] [C] [D] [E] char *p; strcpy(p, s); char *p = NULL; strcpy(p, s); char *p; p = (char *) malloc(strlen(s)); strcpy(p, s); All of the above None of the above Question 5 Consider the following C program: #include <stdio.h> int f(int *x, int y, int *z) { (*x)++; y++; return *z; int main(int argc, char** argv) { int w = 1; int x = 2; int y = 3; int *z; z = &w; printf("w=%d; x=%d; y=%d; z=%p \n", w, x, y, z); f(z, x, &y); printf("w=%d; x=%d; y=%d; z=%p \n", w, x, y, z); return 0; Which variables have a different value printed in the second printf statement? [A] [B] [C] [D] [E] w only x only y only w and y only Some other combination
4 Question 6 The following C program compiles correctly and is run. #include <stdio.h> int main(int argc, char** argv) { int x = 7; printf("%d\n", (1/2) * x); return 0; What does it print? [A] 0 [B] 1 [C] 2 [D] 3 [E] 4 Question 7 Given the following structure definitions: typedef struct { int x; int y; A; typedef struct { int v; A w; B; If we define a variable p as follows: B *p; which one of these is a legal C expression? [A] [B] [C] [D] [E] p.w.y p->w.y p.w->y p->w->y p->a->y
5 Question 8 #include <stdio.h> int main(int argc, char** argv) { int q; int *p = &q; q = 24; *p = 42; q = q + *p; printf("the value of q is %d\n", q); return 0; When the above program is executed what value is printed for the variable q? [A] 0 [B] 24 [C] 42 [D] 66 [E] 84 Question 9 Consider the following C code fragment. #include <stdio.h> #define TRUE 1 int main(int argc, char** argv) { int flag = TRUE; if (flag = 0) { printf("true"); else { printf("false"); return 0; What is printed? [A] 0 [B] 1 [C] [D] [E] False True None of the above
6 Question 10 A programmer is wondering which sort algorithm to use in their program and has just asked you about the speed difference between a sort function which uses the insertion sort algorithm and one which uses the quicksort algorithm. Which of the following can you say? (if more than one is correct select the most informative of them). [A] [B] [C] [D] [E] A quicksort function will always be faster than an insertion sort function An insertion sort function will always be faster than a quicksort function A quicksort function will usually be faster than an insertion sort function An insertion sort function will usually be faster than a quicksort function None of the above
7 Part B: Short Answer Questions Answer these questions in the spaces provided on this pink question paper. DO NOT answer these questions in an answer booklet! Do all your working in the Working Only booklet, your working is not marked in Part B. Write your answers clearly. Keep your answers neat and very brief. Messy or long answers will not be marked. Question 11 (4 marks) (a) Convert binary into decimal. Answer: (b) Convert hexadecimal BEEF into decimal. Answer: (c) Convert decimal 42 into binary. Answer: (d) Convert decimal 42 into hexadecimal. Answer: Question 12 (4 marks) Consider the following 8BMC program: Does it terminate? Answer: If it terminates what is the final value in R1? Answer: Does it print anything? Answer: If it prints something what does it print? (just give the ascii codes it prints, no need to convert them into characters). Answer:
8 Question 13 (4 marks) Consider the following 8BMC program: Does it terminate? Answer: If it terminates what is the final value in R0? Answer: Does it print anything? Answer: If it prints something what does it print? (just give the ascii codes it prints, no need to convert them into characters). Answer: Question 14 (4 marks) The following code was designed to generate a new deck of cards. (deck, suit and value are declared elsewhere).??? x; suit = 0; while (suit < NUM_SUITS) { value = 0; while (value < NUM_VALUES) { x= malloc (sizeof (Node)); assert (x!= NULL); x->next = deck->first; x->card.suit = suit; x->card.value = value; deck->first = x; Finish the declaration of x (replace the??? above). The code shown has two logic errors, fix them (write your corrections above, ie write them directly on the program listing).
9 Question 15 (5 marks) In the space below write a function which reads a integer n using scanf, and then prints all the numbers from 1 to n in order, except not printing any number divisible by 7 or 3. You may assume that n is not negative. For example if n was 15 the output would be The prototype for the function is: void printsome(void); Your function:
10 Question 16 (5 marks) Write a function which, given an integer, prints it in 8 digit binary. For example if the number was 3 the function would print and if the number was 9 it would print and so on. You may assume that the number is less than 256 and is not negative. The prototype for the function is: void printbinary(int n); Your function:
11 Question 17 (6 marks) The following code was designed to shuffle a pile of cards, mimicking the most common human shuffle algorithm. int randomnumber (int n); void swap (PileOfCards first, PileOfCards second); void shuffle (PileOfCards cards, int seed) { // Set seed for rng srand ((unsigned) seed ); int cutsize; PileOfCards discards = newemptypile(); int pilesize = size(cards); int cardsleft; int passes = 0; while (passes < NUM_PASSES) { cardsleft = pilesize; while (cardsleft > 0) { cutsize = randomnumber (MAXIMUM_CUT); printf ("current size %d, cut size %d\n", cardsleft, cutsize); if (cutsize > cardsleft) { cutsize = cardsleft; move (cutsize, cards, discards); cardsleft = cardsleft - cutsize; printf ("current size %d, cut size %d\n", cardsleft, cutsize); swap (cards, discards); printf ("current size %d, cut size %d\n", cardsleft, cutsize); return; // return a random number between 0 and n-1 inclusive int randomnumber (int n) { int bucketsize = 1 + (RAND_MAX / n); return (rand() / bucketsize); void swap (PileOfCards first, PileOfCards second) { PileOfCards temp = first; first = second; second = temp;
12 However it contains a bug, and produces the following unexpected crash: size of a new deck is 52 Enter a shuffle number: 2 current size 52, cut size 0 current size 52, cut size 2 current size 50, cut size 5 current size 45, cut size 9 current size 36, cut size 0 current size 36, cut size 4 current size 32, cut size 0 current size 32, cut size 3 current size 29, cut size 3 current size 26, cut size 8 current size 18, cut size 7 current size 11, cut size 0 current size 11, cut size 6 current size 5, cut size 0 current size 5, cut size 1 current size 4, cut size 0 current size 4, cut size 3 current size 1, cut size 0 current size 1, cut size 7 current size 52, cut size 1 /Users/richardb/clock/PileOfCards.c:85: failed assertion howmany <= from->size State and briefly explain the bug. Correct the bug (write the correction on the program listing above). The bug is:
13 Part C Answer this part in your Part C answer booklet. Start each question on a new page. Make your answers as clear and easy to understand as possible. Provide type definitions and brief comments where necessary. Confusing or illegible solutions will lose marks. If you do not wish your answer for a question to be marked clearly record 1 mark for that question on the front of your Part C answer booklet. If you do this your answer for that question will not be marked. Question 18 (5 marks) Suppose you are writing your code for page turning part of Task 2. You already have a function int areconnected(char page1, char page2); which returns 1 if page1 and page2 are connected, 0 otherwise. Implement a function int cost(char book[num_pages]); which, given book, a proposed layout of the book, returns the largest number of pages which need to be turned to go between two connected pages in that layout. You may assume that the number of pages in the book has been defined elsewhere and is stored in a global constant called NUM_PAGES. Question 19 (9 marks) Write a function which, given a string containing a positive integer and a word, copies the integer and the word into the fields of a struct of this type: typedef struct { int number; char name[256]; Pair; Your function must have this prototype void strtocount(char *string, Pair *pairpointer); You may not use any C library functions. Hence you can NOT use, strcpy, atoi, isdigit etc. Assume the word is a sequence of lower-case alphabaetic charcaters ( a.. z ). Assume the number contains only the digits ( ). Zero or more space characters can occur before the number, between the number and the word and after the word.
14 Question 20 (6 marks) Draw a picture of the stack frame generated when inner is called. In your picture show the contents of the stack as at the instant just before the first call to getchar(). Briefly explain, perhaps using a picture or two to help make your explanation clearer but otherwise taking no more than a paragraph, how a knowledgeable user could enter data and cause the program to immediately execute innerprivileged after executing inner. #include wowamazing.h #include <stdio.h> int inner(int flag, int notused) { int inputchar; int counter=0; char temp[32]; inputchar = getchar(); while (inputchar!= EOF) { temp[counter++] = inputchar; inputchar = getchar(); return flag++; void innerprivileged () { wowamazing(); int main (int argc, char** argv) { int size = 37; size = inner(size,2); somethingnotasamazing(size); return 0; Note: wowamazing and somethingnotasamazing are declared elsewhere.
15 Part D Answer this part in your Part D answer booklet. Start each question and each sub-question on a new page. Partial solutions for a question (i.e. attempts worth less than 50% or for which some subquestions have not been answered) will score no marks in this part. If you do not wish your answer for a question to be marked record 1 mark for that question on the front of the answer booklet. If you do this your answers for all sub-questions of that question will not be marked. Sub-questions are not of equal value. Your solutions must be clear, elegant and easy to understand. In this part confusing or difficult to understand solutions will score no marks. Question 21 (10 marks) In this question everything is defined as for the project except that the sort function is not an interface function of PileOfCards.c but instead is defined in clock.c using the other interface functions from PileOfCards.h. Write a version of sort which uses the insertion sort algorithm. Make sure you treat PileOfCards as abstract and that your sort would work with any correct implementation of PileOfCards.c, not just your own one. Question 22 (11 marks) (a) We want to have an abstract type called Queue which keeps track of students waiting in a queue to be marked by their tutor. We have to work out what functions to put in the interface, and we want the interface to be small so we don t want to include functions which we can derive from outside the interface. So far we have considered: i) join - to add a student to the rear of the queue (defined in (b) below) ii) remove - to remove a student from the front of the queue (defined in (b) below) iii) isempty - returns true if the queue is empty iv) printqueue - to print out all the student numbers in the queue in order v) sort - to sort the queue into order, ranked by student number vi) waiting - returns the number of students waiting in the queue. For each function indicate if it should be in the interface or not, and briefly explain why in one line or less. You may propose additional functions for the interface if you feel the above list is not complete. If you do this state why you would include the extra functions, taking no more than one line for each.
16 (b) To be able to reuse nodes and prevent memory leaks, you have decided to store the queue as a linked list of nodes which is circular. This means that instead of having a last node in the list which points to NULL, every node will point to an actual node, and this will form a connected ring of nodes. You decide not to delete old nodes but to leave them in the ring and reuse them when new nodes are required, and to only create new nodes using malloc when you run out of spare nodes. The interface header file queue.h looks like: typedef int Student; typedef struct ring RingData; typedef RingData *Queue; void join (Queue queue, Student id); void remove (Queue queue);... (rest of interface functions, not needed in this question) The top of queue.c contains the following: typedef struct node Node; typedef Node *Link; struct node { Student id; Next Link; ; struct ring { Link front; Link rear; ; i) For each of the functions join and remove draw a brief diagram showing how they act on the ring of nodes. ii) Write an implementation for each of these two functions.
C0MP1921/2011/2091 SAMPLE Final Exam Data Structures and Algorithms/Data Organisation/Computing 2
Family Name: Other Names: Signature: Student Number: This PAPER is NOT to be retained by the STUDENT The University Of New South Wales C0MP1921/2011/2091 SAMPLE Final Exam Data Structures and Algorithms/Data
More informationECE264 Spring 2013 Final Exam, April 30, 2013
ECE264 Spring 2013 Final Exam, April 30, 2013 In signing this statement, I hereby certify that the work on this exam is my own and that I have not copied the work of any other student while completing
More informationECE264 Fall 2013 Exam 3, November 20, 2013
ECE264 Fall 2013 Exam 3, November 20, 2013 In signing this statement, I hereby certify that the work on this exam is my own and that I have not copied the work of any other student while completing it.
More informationSample Examination. Family Name:... Other Names:... Signature:... Student Number:...
Family Name:... Other Names:... Signature:... Student Number:... THE UNIVERSITY OF NEW SOUTH WALES SCHOOL OF COMPUTER SCIENCE AND ENGINEERING Sample Examination COMP1917 Computing 1 EXAM DURATION: 2 HOURS
More informationCOP Programming Concepts Spring 1999 CLOSED BOOK Exam #1 100 Points NAME
CLOSED BOOK Exam #1 100 Points NAME 1. The following program has (at least) 10 syntax errors. Circle each error. Write the corrected program in the blank space below. 2 points for each error you find.
More informationMidterm Exam Nov 8th, COMS W3157 Advanced Programming Columbia University Fall Instructor: Jae Woo Lee.
Midterm Exam Nov 8th, 2012 COMS W3157 Advanced Programming Columbia University Fall 2012 Instructor: Jae Woo Lee About this exam: - There are 4 problems totaling 100 points: problem 1: 30 points problem
More informationCSE 333 Midterm Exam 5/10/13
Name There are 5 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes, closed
More informationUNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING
UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING APS 105 Computer Fundamentals Midterm Examination October 28, 2008 12:20 p.m. 1:50 p.m. Examiners: Jason Anderson, Tom Fairgrieve, Baochun
More informationMIDTERM TEST EESC 2031 Software Tools June 13, Last Name: First Name: Student ID: EECS user name: TIME LIMIT: 110 minutes
MIDTERM TEST EESC 2031 Software Tools June 13, 2017 Last Name: First Name: Student ID: EECS user name: TIME LIMIT: 110 minutes This is a closed-book test. No books and notes are allowed. Extra space for
More informationFinal Exam 1 /12 2 /12 3 /10 4 /7 5 /4 6 /10 7 /8 8 /9 9 /8 10 /11 11 /8 12 /10 13 /9 14 /13 15 /10 16 /10 17 /12. Faculty of Computer Science
Faculty of Computer Science Page 1 of 21 Final Exam Term: Fall 2018 (Sep4-Dec4) Student ID Information Last name: First name: Student ID #: CS.Dal.Ca userid: Course ID: CSCI 2132 Course Title: Instructor:
More informationProblem 2 Add the two 2 s complement signed 8-bit values given below, and express your answer in decimal.
Problem 1 Recall the definition of root in project 1. (The declaration of struct entrynode appears below.) struct entrynode * root; Give the type of each of the following expressions. The answer may be
More informationMid-term Exam. Fall Semester 2017 KAIST EE209 Programming Structures for Electrical Engineering. Name: Student ID:
Fall Semester 2017 KAIST EE209 Programming Structures for Electrical Engineering Mid-term Exam Name: This exam is closed book and notes. Read the questions carefully and focus your answers on what has
More informationMid-term Exam. Fall Semester 2017 KAIST EE209 Programming Structures for Electrical Engineering. Name: Student ID:
Fall Semester 2017 KAIST EE209 Programming Structures for Electrical Engineering Mid-term Exam Name: This exam is closed book and notes. Read the questions carefully and focus your answers on what has
More informationCSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community
CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community http://csc.cs.rit.edu History and Evolution of Programming Languages 1. Explain the relationship between machine
More informationCS 2301 Exam 3 B-Term 2011
NAME: CS 2301 Exam 3 B-Term 2011 Questions 1-3: (15) Question 4: (15) Question 5: (20) Question 6: (10) Question 7: (15) Question 8: (15) Question 9: (10) TOTAL: (100) You may refer to one sheet of notes
More informationYork University AS/AK/ITEC INTRODUCTION TO DATA STRUCTURES. Midterm Sample I. Examiner: S. Chen Duration: One Hour and 30 Minutes
York University AS/AK/ITEC 2620 3.0 INTRODUCTION TO DATA STRUCTURES Midterm Sample I Examiner: S. Chen Duration: One Hour and 30 Minutes This exam is closed textbook(s) and closed notes. Use of any electronic
More informationCIS 110 Introduction to Computer Programming. February 29, 2012 Midterm
CIS 110 Introduction to Computer Programming February 29, 2012 Midterm Name: Recitation # (e.g. 201): Pennkey (e.g. bjbrown): My signature below certifies that I have complied with the University of Pennsylvania
More informationVariables Data types Variable I/O. C introduction. Variables. Variables 1 / 14
C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition
More informationCSE 333 Midterm Exam Sample Solution 5/10/13
Question 1. (18 points) Consider these two C files: a.c void f(int p); int main() { f(17); return 0; b.c void f(char *p) { *p = 'x'; (a) Why is the program made from a.c and b.c incorrect? What would you
More informationSCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177. Programming
s SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177 Programming Time allowed: THREE hours: Answer: ALL questions Items permitted: Items supplied: There is
More informationINDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator EXAMINATION ( End Semester ) SEMESTER ( Spring ) Roll Number Section Name Subject Number C S 1 0 0 0 1 Subject Name Programming
More informationCMSC 212 Midterm #2 (Fall 2005) ANSWERS AND GRADING KEY
CMSC 212 Midterm #2 (Fall 2005) ANSWERS AND GRADING KEY Discussion Section Time (circle one): 12:00 1:00 2:00 3:00 4:00 5:00 Elena Sorelle Morgan (1) This exam is closed book, closed notes, and closed
More informationMain Program. C Programming Notes. #include <stdio.h> main() { printf( Hello ); } Comments: /* comment */ //comment. Dr. Karne Towson University
C Programming Notes Dr. Karne Towson University Reference for C http://www.cplusplus.com/reference/ Main Program #include main() printf( Hello ); Comments: /* comment */ //comment 1 Data Types
More informationECE264 Spring 2014 Exam 2, March 11, 2014
ECE264 Spring 2014 Exam 2, March 11, 2014 In signing this statement, I hereby certify that the work on this exam is my own and that I have not copied the work of any other student while completing it.
More informationECE264 Fall 2013 Exam 1, September 24, 2013
ECE264 Fall 2013 Exam 1, September 24, 2013 In signing this statement, I hereby certify that the work on this exam is my own and that I have not copied the work of any other student while completing it.
More informationC: Arrays, and strings. Department of Computer Science College of Engineering Boise State University. September 11, /16
Department of Computer Science College of Engineering Boise State University September 11, 2017 1/16 1-dimensional Arrays Arrays can be statically declared in C, such as: int A [100]; The space for this
More informationMidterm Exam 2 Solutions C Programming Dr. Beeson, Spring 2009
Midterm Exam 2 Solutions C Programming Dr. Beeson, Spring 2009 April 16, 2009 Instructions: Please write your answers on the printed exam. Do not turn in any extra pages. No interactive electronic devices
More informationCSE 333 Midterm Exam 2/12/16. Name UW ID#
Name UW ID# There are 6 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes,
More informationAnswer all questions. Write your answers only in the space provided. Full marks = 50
Answer all questions. Write your answers only in the space provided. Full marks = 50 1. Answer the following: [2+3+2+1=8 marks] a) What are the minimum and maximum numbers that can be represented in 10-bit
More informationCpSc 1111 Lab 5 Formatting and Flow Control
CpSc 1111 Lab 5 Formatting and Flow Control Overview By the end of the lab, you will be able to: use fscanf() to accept a character input from the user execute a basic block iteratively using loops to
More informationComputer Science Foundation Exam
Computer Science Foundation Exam December 16, 2016 Section I A DATA STRUCTURES NO books, notes, or calculators may be used, and you must work entirely on your own. SOLUTION Question # Max Pts Category
More informationCS 0449 Sample Midterm
Name: CS 0449 Sample Midterm Multiple Choice 1.) Given char *a = Hello ; char *b = World;, which of the following would result in an error? A) strlen(a) B) strcpy(a, b) C) strcmp(a, b) D) strstr(a, b)
More informationECE 264 Exam 2. 6:30-7:30PM, March 9, You must sign here. Otherwise you will receive a 1-point penalty.
ECE 264 Exam 2 6:30-7:30PM, March 9, 2011 I certify that I will not receive nor provide aid to any other student for this exam. Signature: You must sign here. Otherwise you will receive a 1-point penalty.
More information: Principles of Imperative Computation Victor Adamchik. Practice Exam - I
15-122 Practice Exam - I Page 1 of 10 15-122 : Principles of Imperative Computation Victor Adamchik Practice Exam - I Name: Andrew ID: Answer the questions in the space provided following each question.
More informationUNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING
UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING APS 105 Computer Fundamentals Final Examination December 16, 2013 2:00 p.m. 4:30 p.m. (150 minutes) Examiners: J. Anderson, B. Korst, J.
More informationHigh-performance computing and programming Intro to C on Unix/Linux. Uppsala universitet
High-performance computing and programming Intro to C on Unix/Linux IT Uppsala universitet What is C? An old imperative language that remains rooted close to the hardware C is relatively small and easy
More informationC Review. MaxMSP Developers Workshop Summer 2009 CNMAT
C Review MaxMSP Developers Workshop Summer 2009 CNMAT C Syntax Program control (loops, branches): Function calls Math: +, -, *, /, ++, -- Variables, types, structures, assignment Pointers and memory (***
More informationBristol Institute of Technology
Bristol Institute of Technology Academic Year: 09/10 Module Leader: Module Code: Title of Module: Ian Johnson UFCETS-20-1 Programming in C Examination Date: Monday 12 th January 2009 Examination Start
More informationComputer Science Foundation Exam
Computer Science Foundation Exam August 26, 2017 Section I A DATA STRUCTURES NO books, notes, or calculators may be used, and you must work entirely on your own. Name: UCFID: NID: Question # Max Pts Category
More informationCSE 333 Midterm Exam July 24, Name UW ID#
Name UW ID# There are 6 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes,
More informationTHE UNIVERSITY OF WESTERN ONTARIO. COMPUTER SCIENCE 211a FINAL EXAMINATION 17 DECEMBER HOURS
Computer Science 211a Final Examination 17 December 2002 Page 1 of 17 THE UNIVERSITY OF WESTERN ONTARIO LONDON CANADA COMPUTER SCIENCE 211a FINAL EXAMINATION 17 DECEMBER 2002 3 HOURS NAME: STUDENT NUMBER:
More informationUNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING
UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING APS 105 Computer Fundamentals Final Examination December 14, 2012 2:00 p.m. 4:30 p.m. (150 minutes) Examiners: J. Anderson, B. Li, M. Sadoghi,
More informationProcedures, Parameters, Values and Variables. Steven R. Bagley
Procedures, Parameters, Values and Variables Steven R. Bagley Recap A Program is a sequence of statements (instructions) Statements executed one-by-one in order Unless it is changed by the programmer e.g.
More informationCSE 333 Midterm Exam Sample Solution 7/28/14
Question 1. (20 points) C programming. For this question implement a C function contains that returns 1 (true) if a given C string appears as a substring of another C string starting at a given position.
More informationCS16 Exam #1 7/17/ Minutes 100 Points total
CS16 Exam #1 7/17/2012 75 Minutes 100 Points total Name: 1. (10 pts) Write the definition of a C function that takes two integers `a` and `b` as input parameters. The function returns an integer holding
More informationCSci 4061 Introduction to Operating Systems. Programs in C/Unix
CSci 4061 Introduction to Operating Systems Programs in C/Unix Today Basic C programming Follow on to recitation Structure of a C program A C program consists of a collection of C functions, structs, arrays,
More informationSU 2017 May 11/16 LAB 2: Character and integer literals, number systems, character arrays manipulation, relational operator
SU 2017 May 11/16 LAB 2: Character and integer literals, number systems, character arrays manipulation, relational operator 0 Problem 0 number bases Visit the website www.cleavebooks.co.uk/scol/calnumba.htm
More informationCSE 250 Final Exam. Fall 2013 Time: 3 hours. Dec 11, No electronic devices of any kind. You can open your textbook and notes
CSE 250 Final Exam Fall 2013 Time: 3 hours. Dec 11, 2013 Total points: 100 14 pages Please use the space provided for each question, and the back of the page if you need to. Please do not use any extra
More informationUniversity of California, Berkeley College of Engineering
University of California, Berkeley College of Engineering Department of Electrical Engineering and Computer Sciences Summer 2016 Instructors: Shreyas Chand, Justin Hsia 2016-07-07 Last Name (Please print
More informationLaboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information
Laboratory 2: Programming Basics and Variables Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information 3. Comment: a. name your program with extension.c b. use o option to specify
More informationECE264 Fall 2013 Exam 2, October 24, 2013
ECE Fall 0 Exam, October, 0 If this is an on-line exam, you have 0 minutes to finish the exam. When the time limit is reached, the system will automatically close. If this is a paper exam, you have 0 minutes.
More informationCOS 126 MIDTERM 1, FALL
COS 126 MIDTERM 1, FALL 2000 1 This test has 12 questions worth a total of 50 points. You have 120 minutes. The exam is closed book, except that you are allowed to use a one page cheatsheet. No calculators
More informationINDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR Stamp / Signature of the Invigilator EXAMINATION ( End Semester ) SEMESTER ( Autumn ) Roll Number Section Name Subject Number C S Subject Name Programming and Data
More informationC BOOTCAMP DAY 2. CS3600, Northeastern University. Alan Mislove. Slides adapted from Anandha Gopalan s CS132 course at Univ.
C BOOTCAMP DAY 2 CS3600, Northeastern University Slides adapted from Anandha Gopalan s CS132 course at Univ. of Pittsburgh Pointers 2 Pointers Pointers are an address in memory Includes variable addresses,
More informationMidterm Exam 2 Solutions, C programming
Midterm Exam 2 Solutions, C programming April 26, 2010 Rules: Open book, open notes, open any printed or handwritten material. No electronic devices (except a music player). If you use a music player nobody
More informationNote: unless otherwise stated, the questions are with reference to the C Programming Language. You may use extra sheets if need be.
CS 156 : COMPUTER SYSTEM CONCEPTS TEST 1 (C PROGRAMMING PART) FEBRUARY 6, 2001 Student s Name: MAXIMUM MARK: 100 Time allowed: 45 minutes Note: unless otherwise stated, the questions are with reference
More informationLecture 12 CSE July Today we ll cover the things that you still don t know that you need to know in order to do the assignment.
Lecture 12 CSE 110 20 July 1992 Today we ll cover the things that you still don t know that you need to know in order to do the assignment. 1 The NULL Pointer For each pointer type, there is one special
More informationLecture 04 Introduction to pointers
Lecture 04 Introduction to pointers A pointer is an address in the memory. One of the unique advantages of using C is that it provides direct access to a memory location through its address. A variable
More informationFinal CSE 131B Spring 2004
Login name Signature Name Student ID Final CSE 131B Spring 2004 Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7 Page 8 (25 points) (24 points) (32 points) (24 points) (28 points) (26 points) (22 points)
More informationUNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING
UNIVERSITY OF TORONTO FACULTY OF APPLIED SCIENCE AND ENGINEERING APS 105 Computer Fundamentals Final Examination December 9, 2011 9:30 a.m. 12:00 p.m. Examiners: J. Anderson, T. Fairgrieve, B. Li, G. Steffan,
More informationCSE 12 Spring 2016 Week One, Lecture Two
CSE 12 Spring 2016 Week One, Lecture Two Homework One and Two: hw2: Discuss in section today - Introduction to C - Review of basic programming principles - Building from fgetc and fputc - Input and output
More informationUnited States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring AY2017
United States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring AY2017 1. Do a page check: you should have 8 pages including this cover sheet. 2. You have 50 minutes
More informationEECE.2160: ECE Application Programming Fall 2017 Exam 3 December 16, 2017
EECE.2160: ECE Application Programming Fall 2017 Exam 3 December 16, 2017 Name: Lecture time (circle 1): 8-8:50 (Sec. 201) 12-12:50 (Sec. 203) 1-1:50 (Sec. 202) For this exam, you may use only one 8.5
More informationCOS 126 General Computer Science Fall Midterm 1
COS 126 General Computer Science Fall 2001 Midterm 1 This test has 11 questions worth a total of 50 points. You have 120 minutes. The exam is closed book, except that you are allowed to use a one page
More informationLab Exam 1 D [1 mark] Give an example of a sample input which would make the function
CMPT 127 Spring 2019 Grade: / 20 First name: Last name: Student Number: Lab Exam 1 D400 1. [1 mark] Give an example of a sample input which would make the function scanf( "%f", &f ) return -1? Answer:
More informationcs3157: another C lecture (mon-21-feb-2005) C pre-processor (3).
cs3157: another C lecture (mon-21-feb-2005) C pre-processor (1). today: C pre-processor command-line arguments more on data types and operators: booleans in C logical and bitwise operators type conversion
More informationPrograms in memory. The layout of memory is roughly:
Memory 1 Programs in memory 2 The layout of memory is roughly: Virtual memory means that memory is allocated in pages or segments, accessed as if adjacent - the platform looks after this, so your program
More informationDalhousie University CSCI 2132 Software Development Winter 2018 Midterm Examination II March 12 15:37-16:24
Dalhousie University CSCI 2132 Software Development Winter 2018 Midterm Examination II March 12 15:37-16:24 Student Name: Student ID Number: FCS Username (CSID): Signature: Please Note: These solutions
More informationLab Exam 1 D [1 mark] Give an example of a sample input which would make the function
Grade: / 20 Lab Exam 1 D500 1. [1 mark] Give an example of a sample input which would make the function scanf( "%f", &f ) return 0? Answer: Anything that is not a floating point number such as 4.567 or
More informationCIS 110 Introduction to Computer Programming Spring 2016 Midterm
CIS 110 Introduction to Computer Programming Spring 2016 Midterm Name: Recitation # (e.g., 201): Pennkey (e.g., eeaton): My signature below certifies that I have complied with the University of Pennsylvania
More informationCpSc 1111 Lab 4 Formatting and Flow Control
CpSc 1111 Lab 4 Formatting and Flow Control Overview By the end of the lab, you will be able to: use fscanf() to accept a character input from the user and print out the ASCII decimal, octal, and hexadecimal
More informationAryan College. Fundamental of C Programming. Unit I: Q1. What will be the value of the following expression? (2017) A + 9
Fundamental of C Programming Unit I: Q1. What will be the value of the following expression? (2017) A + 9 Q2. Write down the C statement to calculate percentage where three subjects English, hindi, maths
More informationCSE 333 Midterm Exam 2/14/14
Name There are 4 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes, closed
More information#include <iostream> #include <algorithm> #include <cmath> using namespace std; int f1(int x, int y) { return (double)(x/y); }
1. (9 pts) Show what will be output by the cout s in this program. As in normal program execution, any update to a variable should affect the next statement. (Note: boolalpha simply causes Booleans to
More informationUNIVERSITY OF WINDSOR Fall 2007 QUIZ # 2 Solution. Examiner : Ritu Chaturvedi Dated :November 27th, Student Name: Student Number:
UNIVERSITY OF WINDSOR 60-106-01 Fall 2007 QUIZ # 2 Solution Examiner : Ritu Chaturvedi Dated :November 27th, 2007. Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) No calculators allowed.
More informationComputer Architecture I Mid-Term I
Computer Architecture I Mid-Term I April 19 2018 Computer Architecture I Mid-Term I Chinese Name: Pinyin Name: E-Mail... @shanghaitech.edu.cn: Question Points Score 1 1 2 11 3 10 4 9 5 14 6 29 7 14 8 12
More informationThis is CS50. Harvard University Fall Quiz 0 Answer Key
Quiz 0 Answer Key Answers other than the below may be possible. Binary Bulbs. 0. Bit- Sized Questions. 1. Because 0 is non- negative, we need to set aside one pattern of bits (000) for it, which leaves
More informationComputer Science 302 Spring 2018 Practice Examination for the Second Examination,
Computer Science 302 Spring 2018 Practice Examination for the Second Examination, March 7, 2018 Name: No books, notes, or scratch paper. Use pen or pencil, any color. Use the rest of this page and the
More informationC Data Structures Stacks. Stack. push Adds a new node to the top of the stack
1 12 C Data Structures 12.5 Stacks 2 Stack New nodes can be added and removed only at the top Similar to a pile of dishes Last-in, first-out (LIFO) Bottom of stack indicated by a link member to NULL Constrained
More informationThe University of Nottingham
The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, AUTUMN SEMESTER 2008 2009 C/C++ for Java Programmers Time allowed TWO hours Candidates may complete the front cover of their answer
More informationCS Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2015
CS 141 - Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2015 You may take this test with you after the test, but you must turn in your answer sheet. This test has the following sections:
More informationIntroduction to C. Sean Ogden. Cornell CS 4411, August 30, Geared toward programmers
Introduction to C Geared toward programmers Sean Ogden Slide heritage: Alin Dobra Niranjan Nagarajan Owen Arden Robert Escriva Zhiyuan Teo Ayush Dubey Cornell CS 4411, August 30, 2013 Administrative Information
More informationSample Problems for Quiz # 2
EE 1301 UMN Introduction to Computing Systems Fall 2013 Sample Problems for Quiz # 2 (with solutions) Here are sample problems to help you prepare for Quiz 2 on Oct. 31. 1. Bit-Level Arithmetic (a) Consider
More informationCSE 30 Fall 2012 Final Exam
Login: cs30x Student ID Name Signature By filling in the above and signing my name, I confirm I will complete this exam with the utmost integrity and in accordance with the Policy on Integrity of Scholarship.
More informationCS3157: Advanced Programming. Outline
CS3157: Advanced Programming Lecture #8 Feb 27 Shlomo Hershkop shlomo@cs.columbia.edu 1 Outline More c Preprocessor Bitwise operations Character handling Math/random Review for midterm Reading: k&r ch
More informationActually, C provides another type of variable which allows us to do just that. These are called dynamic variables.
When a program is run, memory space is immediately reserved for the variables defined in the program. This memory space is kept by the variables until the program terminates. These variables are called
More informationKurt Schmidt. October 30, 2018
to Structs Dept. of Computer Science, Drexel University October 30, 2018 Array Objectives to Structs Intended audience: Student who has working knowledge of Python To gain some experience with a statically-typed
More informationIntroduction to C. Ayush Dubey. Cornell CS 4411, August 31, Geared toward programmers
Introduction to C Geared toward programmers Ayush Dubey Slide heritage: Alin Dobra Niranjan Nagarajan Owen Arden Robert Escriva Zhiyuan Teo Cornell CS 4411, August 31, 2012 Administrative Information Outline
More informationUNIT - I. Introduction to C Programming. BY A. Vijay Bharath
UNIT - I Introduction to C Programming Introduction to C C was originally developed in the year 1970s by Dennis Ritchie at Bell Laboratories, Inc. C is a general-purpose programming language. It has been
More informationGood Luck! Marking Guide. APRIL 2014 Final Exam CSC 209H5S
APRIL 2014 Final Exam CSC 209H5S Last Name: Student #: First Name: Signature: UNIVERSITY OF TORONTO MISSISSAUGA APRIL 2014 FINAL EXAMINATION CSC209H5S System Programming Daniel Zingaro Duration - 3 hours
More informationEL2310 Scientific Programming
Lecture 11: Memory, Files and Bitoperations (yaseminb@kth.se) Overview Overview Lecture 11: Memory, Files and Bit operations Main function; reading and writing Bitwise Operations Lecture 11: Memory, Files
More informationStorage class and Scope:
Algorithm = Logic + Control + Data Data structures and algorithms Data structures = Ways of systematically arranging information, both abstractly and concretely Algorithms = Methods for constructing, searching,
More informationUnited States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring 2015
United States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring 2015 1. Do a page check: you should have 8 pages including this cover sheet. 2. You have 50 minutes
More informationWawrzynek & Weaver CS 61C. Sp 2018 Great Ideas in Computer Architecture MT 1. Print your name:,
Wawrzynek & Weaver CS 61C Sp 2018 Great Ideas in Computer Architecture MT 1 Print your name:, (last) (first) I am aware of the Berkeley Campus Code of Student Conduct and acknowledge that any academic
More informationCS 223: Data Structures and Programming Techniques. Exam 2
CS 223: Data Structures and Programming Techniques. Exam 2 Instructor: Jim Aspnes Work alone. Do not use any notes or books. You have approximately 75 minutes to complete this exam. Please write your answers
More informationArrays. An array is a collection of several elements of the same type. An array variable is declared as array name[size]
(November 10, 2009 2.1 ) Arrays An array is a collection of several elements of the same type. An array variable is declared as type array name[size] I The elements are numbered as 0, 1, 2... size-1 I
More informationInformatica e Sistemi in Tempo Reale
Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 5, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction
More informationCS61, Fall 2012 Section 2 Notes
CS61, Fall 2012 Section 2 Notes (Week of 9/24-9/28) 0. Get source code for section [optional] 1: Variable Duration 2: Memory Errors Common Errors with memory and pointers Valgrind + GDB Common Memory Errors
More informationComputer Science & Information Technology (CS) Rank under AIR 100. Examination Oriented Theory, Practice Set Key concepts, Analysis & Summary
GATE- 2016-17 Postal Correspondence 1 C-Programming Computer Science & Information Technology (CS) 20 Rank under AIR 100 Postal Correspondence Examination Oriented Theory, Practice Set Key concepts, Analysis
More informationMULTIMEDIA COLLEGE JALAN GURNEY KIRI KUALA LUMPUR
STUDENT IDENTIFICATION NO MULTIMEDIA COLLEGE JALAN GURNEY KIRI 54100 KUALA LUMPUR FIFTH SEMESTER FINAL EXAMINATION, 2014/2015 SESSION PSD2023 ALGORITHM & DATA STRUCTURE DSEW-E-F-2/13 25 MAY 2015 9.00 AM
More information