University of Calgary Department of Electrical and Computer Engineering ENCM 339: Programming Fundamentals, Section 01 Instructor: Steve Norman
|
|
- Harold Mitchell
- 5 years ago
- Views:
Transcription
1 page 1 of 9 University of Calgary Department of Electrical and Computer Engineering ENCM 339: Programming Fundamentals, Section 01 Instructor: Steve Norman Fall 2017 FINAL EXAMINATION Location: ENG 60 Monday, December 11 Noon to 3:00 PM NAME (printed): Please don t write anything within this box. 1 / 10 2 / 12 U of C ID NUMBER: 3 / 9 4 / 12 5 / 5 SIGNATURE: 6 / 9 7 / 10 8 / 9 TOTAL / 76 Version information This docuemnt is very slightly different from the one that was printed and given to students. A typographical error has been corrected on page 5, and some text has been edited on page 7 to clarify the specifications of the functions students were asked to write. Instructions Please note that the official University of Calgary examination regulations are printed on page 1 of the Examination Regulations and Reference Material booklet that accompanies this examination paper. All of those regulations are in effect for this examination, except that you must write your answers on the question paper, not in the examination booklet. Calculators may not be used while writing this examination. The examination is closed-book. You may not refer to books or notes during the examination, with one exception: you may refer to the Examination Regulations and Reference Material booklet that accompanies this examination paper. You are not required to add comments to C or Python code you write, but you are strongly encouraged to do so, because writing good comments will improve the probability that your code is correct and will help you to check your code after it is finished. Some problems are relatively easy and some are relatively difficult. Go after the easy marks first. Write all answers on the question paper and hand in the question paper when you are done. Please do not hand in the Examination Regulations and Reference Material booklet. Please print or write your answers legibly. What cannot be read cannot be marked. If you write anything you do not want marked, put a large X through it and write rough work beside it. You may use the backs of pages for rough work.
2 ENCM 339 Fall 2017 Section 01 Final Examination page 2 of 9 PROBLEM 1 (total of 10 marks) Part a (5 marks). Make a memory diagram for the second time the program gets to point one. int add(const int *a, int m) { int s = a[0], i; // point one for (i = 2; i < m; i += 2) s += a[i]; return s; void foo(const int *b, int n, int *p, int *q) { *p = add(b, n); *q = add(b + 1, n - 1); int x[ ] = { 2, 3, 5, 7, 11, 13, 17 ; int j, k; foo(x, 7, &j, &k); Part b (5 marks). Here are some facts relevant to this part of the problem: isspace returns a nonzero value if its argument is a whitespace character (such as space or tab), and zero otherwise. isdigit returns a nonzero value if its argument is one of 0, 1, 2,..., 9, and zero otherwise. ASCII codes for digits are 48, 49, 50,..., 57. Make a memory diagram for the second time the program gets to point one. #include <ctype.h> int getint(const char *s, const char **n) { int r = 0; while (isspace(*s)) s++; while (isdigit(*s)) { r = 10 * r + (*s - 48); s++; // point one *n = s; return r; char foo[ ] = " "; int i1, i2; const char *p; i1 = getint(foo, &p); i2 = getint(p, &p); // point two Hint: At point two the values of i1 and i2 will be 23 and 456.
3 ENCM 339 Fall 2017 Section 01 Final Examination page 3 of 9 PROBLEM 2 (total of 12 marks) Part a (6 marks). Write a complete C function definition to match the given function interface. void remove(char *dest, const char *s1, const char *s2); // REQUIRES: s1 and s2 point to the starts of strings. dest points // to the start of an array of length at least strlen(s1) + 1. // PROMISES: A string is built in the dest array by copying characters // from the s1 string that are NOT in the s2 string. // EXAMPLE: remove(d, "programming", "aeiou") would put "prgrmmng" in // the array found with d. Part b (6 marks). In a two-dimensional coordinate system, the distance from a point (x, y) to the origin is x 2 + y 2. Write a complete C function definition to match the given function interface. (Hint: You will need to do some multiplying and adding, but won t need to take square roots.) struct point { double x, y; ; typedef struct point point_t; int i_of_max_dist(const point_t *a, int n); // REQUIRES: n >= 1, elements a[0]... a[n-1] exist. // PROMISES: Return value is the index of the element that has the // maximum distance from the origin. In the case of a tie, the // the smallest index of a maximum is chosen.
4 ENCM 339 Fall 2017 Section 01 Final Examination page 4 of 9 PROBLEM 3 (total of 9 marks). Miscellaneous short-answer questions about C. Part a (3 marks). Write the program output in the space below the program listing. #include <stdio.h> #define DIV(a, b) a / b #define SUB(c, d) c - d printf("div(20.0, DIV(4.0, 2.0)) is %f\n", DIV(20.0, DIV(4.0, 2.0))); printf("div(10, SUB(8, 3)) is %d\n", DIV(10, SUB(8, 3))); Part b (3 marks). Assume that the call to fopen is successful, that the contents of text file stuff.txt are as shown, and that the program is running on a platform where EOF is 1. #include <stdio.h> FILE *fp = fopen("stuff.txt", "r"); int code, last = -1, count = 0; while (1) { code = fscanf(fp, "%d", &last); if (code!= 1) break; count++; printf("code: %d; last: %d; count: %d\n", code, last, count); stuff.txt xyz What is the program output? Part c (3 marks). Write the program output in the space beside the program listing. Hint: 779 = #include <stdio.h> void do_something(int n) { static char hd[] = " abcdef"; char c; printf("got %d\n", n); if (n <= 15) c = hd[n]; else { do_something(n / 16); c = hd[n % 16]; fputc(c, stdout); do_something(779); printf("\nbye!\n");
5 ENCM 339 Fall 2017 Section 01 Final Examination page 5 of 9 PROBLEM 4 (total of 12 marks). The following program shows one way to program with matrices in C using a struct type and dynamically allocated arrays. If the malloc calls in init_mat succeed, the state of the program at point one will be what is shown in the diagram. #include <stdlib.h> #include <stdio.h> struct matrix { int nrow; int ncol; double **e; ; typedef struct matrix matrix_t; void init_mat(matrix_t *m, int nr, int nc) { m->e = malloc(nr * sizeof(double*)); double *block2 = malloc(nr * nc * sizeof(double)); int i; for (i = 0; i < nr; i++) m->e[i] = block2 + i * nc; m->nrow = nr; m->ncol = nc; double v[3]; matrix_t a; int s; init_mat(&a, 2, 3); for (int r = 0; r < 2; r++) for (int c = 0; c < 3; c++) a.e[r][c] = r * (c + 1); AR main point one a v[0] v[2] s nrow ncol e???????? 2 3 no parameters stack heap // point one get_col_sums(&a, v); s = save_to_file(&a, "my_mat.dat"); if (s!= 0) fprintf(stderr, "error (code %d) saving matrix to file!\n", s); Part a (6 marks). The function get_col_sums is supposed to compute the sums of the columns of a matrix. In the example that would make v[0] = , v[1] = , and v[2] = Write a definition for get_col_sums. Assume that the matrix it works with has been set up by init_mat, but that the numbers of rows and columns could be any positive integers, not necessarily 2 and 3. Part b is on the next page...
6 ENCM 339 Fall 2017 Section 01 Final Examination page 6 of 9 Part b (6 marks). For the matrix type introduced on the previous page, the save_to_file function is supposed to save a matrix in the binary file format shown to the right of this paragraph. (You may assume for this part that the size of an int is 4 bytes and the size of a double is 8 bytes.) Write a definition for save_to_file. Assume that the matrix the function works with has been set up by init_mat, but that the numbers of rows and columns could be any positive integers, not necessarily 2 and 3. The return value should be 0 for success, 1 for failure to open the file, and 2 if a problem is detected trying to close the file. 8 bytes: m, a, t, r, i, x, 1, 7, 4 bytes: nrow 4 bytes: ncol 8 ncol bytes: row 0 of matrix. 8 ncol bytes: last row of matrix PROBLEM 5 (5 marks). Assume that the calls to malloc succeed in the program given below. In the space beside the program listing, draw a memory diagram for the first time the program gets to point one. #include <stdlib.h> #include <string.h> char **clone(char **p, int n) { char **result = malloc(n * sizeof(char *)); int i, j; for (i = 0; i < n; i++) { result[i] = malloc(strlen(p[i]) + 1); for (j = 0; p[i][j]!= \0 ; j++) { result[i][j] = p[i][j]; // point one result[i][j] = \0 ; return result; char *x[3] = {"ABC", "DE", "F"; char **y; y = clone(x, 3);
7 ENCM 339 Fall 2017 Section 01 Final Examination page 7 of 9 PROBLEM 6 (total of 9 marks). Miscellaneous short-answer questions about Python. Part a (3 marks). The add method of a class will be called if an object of that class is the left operand of the binary + operator, and the radd method of a class will be called if an object of that class is the right operand of the binary + operator. class Weirdo(): def init (self, s1, s2): self.s1 = s1 self.s2 = s2 def str (self): return Weirdo( + self.s1 +, + self.s2 + ) def add (self, rhs): return Weirdo(self.s1 + rhs, self.s2 + rhs) class WeirdoToo(Weirdo): def radd (self, lhs): return WeirdoToo(lhs + self.s1, lhs + self.s2) x = Weirdo( A, B ) y = x + C z = WeirdoToo( D, E ) z = F + z print(x, y, z) print( x a WeirdoToo?, isinstance(x, WeirdoToo)) print( z a Weirdo?, isinstance(z, Weirdo)) What is the output of the above program? Part b (3 marks). Note that attempting to evaluate something like int( xyz ) will raise a ValueError exception. Write the program output in the space beside the program listing. chunks = nope 101 #$%! for c1 in chunks.split(): try: i = int(c1) print( c1 as int:, i) except ValueError: print( not an int:, c1) try: for c2 in chunks.split(): i = int(c2) print( c2 as int:, i) except ValueError: print( not an int:, c2) Part c (3 marks). Write the program output in the space beside the program listing. def addem(x, lo, hi): print( lo =, lo, hi =, hi) if lo + 1 == hi: r = x[lo] else: mid = (lo + hi) // 2 r = addem(x, lo, mid) r += addem(x, mid, hi) print( r =, r) return r a = [5, 7, 11] print( starting... ) s = addem(a, 0, 3) print( done... s =, s)
8 ENCM 339 Fall 2017 Section 01 Final Examination page 8 of 9 PROBLEM 7 (total of 10 marks). In both parts, you do not need to write code to check for invalid parameter types or values. Part a (6 marks). Simpson s rule is an algorithm for finding the approximate value of the definite integral b a f(x)dx, by adding up some weighted values of f(x) for a finite number of evenly-spaced values of x between a and b. A parameter n indicates that n + 1 values of f(x) will be used to make the approximation. The sketch to the right uses n = 6. f(x) a x 1 x 2 x 3 x 4 x 5 b x Given a positive even integer n, the general formula for the approximate integral is ( ) b a ( f(a) + 4f(x 1 ) + 2f(x 2 ) + + 2f(x n 2) + 4f(x n 1) + f(b)) 3n Note that f(x k ) gets multiplied by 4 if k is odd and by 2 if k is even. Complete the following Python function definition. def simpson(f, a, b, n): """Return approximate integral of f(x) from x=a to x=b with parameter n. f must be a function that takes one float argument and return a float. n must be an int that is even and positive.""" Part b (4 marks). Write a Python function called maxcount that has one parameter a non-empty sequence of int values and returns the maximum value for the sequence along with the number of times that value is in the sequence. For example... biggest, howmany = maxcount((1, 7, 7, 6, 7))... should give biggest a value of 7 and howmany a value of 3.
9 ENCM 339 Fall 2017 Section 01 Final Examination page 9 of 9 PROBLEM 8 (9 marks) Joe Student sells bunches of bananas, bags of apples, and bags of oranges to help raise tuition money. Because this is an exam question and not real life, he records his sales in text files that look like this example: 2017 dec 4 10 apples 14 oranges 2017 dec 5 20 oranges 19 bananas 6 apples 2017 dec 6 23 bananas 2017 dec dec 8 16 bananas 22 oranges The first line of the example file indicates that on December 4, 2017, Joe sold 10 bags of apples and 14 bags of oranges, but no bunches of bananas. You can assume that every line of every file has space-separated fields with this organization: The first 3 fields describe a date. The remaining fields are in pairs an integer followed by a type of fruit. Your goal is to write a program to add up total sales in one of these input files. For example, for the above input file, the output should be something like this: 58 bunches of bananas 16 bags of apples 56 bags of oranges Complete the Python program started below. Note that it assumes that the name of the input file will be given by sys.argv[1]. You do not have to write code to check for failure to open the input file or for invalid data in input file. import sys if len(sys.argv)!= 2: print( wrong number of command-line arguments ) sys.exit(1) counts = { apples : 0, bananas : 0, oranges : 0
The University of Calgary. ENCM 339 Programming Fundamentals Fall 2016
The University of Calgary ENCM 339 Programming Fundamentals Fall 2016 Instructors: S. Norman, and M. Moussavi Wednesday, November 2 7:00 to 9:00 PM The First Letter of your Last Name:! Please Print your
More informationUniversity of Calgary Department of Electrical and Computer Engineering ENCM 335 Instructor: Steve Norman
page 1 of 6 University of Calgary Department of Electrical and Computer Engineering ENCM 335 Instructor: Steve Norman Fall 2018 MIDTERM TEST Thursday, November 1 6:30pm to 8:30pm Please do not write your
More informationUniversity of Calgary Department of Electrical and Computer Engineering ENCM 339 Lecture Section 01 Instructor: Steve Norman
page 1 of 6 University of Calgary Department of Electrical and Computer Engineering ENCM 339 Lecture Section 01 Instructor: Steve Norman Fall 2017 MIDTERM TEST Wednesday, November 1 7:00pm to 9:00pm This
More informationESC101N: Fundamentals of Computing End-sem st semester
ESC101N: Fundamentals of Computing End-sem 2010-11 1st semester Instructor: Arnab Bhattacharya 8:00-11:00am, 15th November, 2010 Instructions 1. Please write your name, roll number and section below. 2.
More information#1 #2 with corrections Monday, March 12 7:00pm to 8:30pm. Please do not write your U of C ID number on this cover page.
page 1 of 6 University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Lecture Instructors: Steve Norman and Norm Bartley Winter 2018 MIDTERM TEST #1 #2 with
More informationSlide Set 8. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng
Slide Set 8 for ENCM 339 Fall 2017 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary October 2017 ENCM 339 Fall 2017 Section 01 Slide
More informationWinter 2017 MIDTERM TEST #1 Wednesday, February 8 7:00pm to 8:30pm. Please do not write your U of C ID number on this cover page.
page 1 of 5 University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Lecture Instructors: Steve Norman and Norm Bartley Winter 2017 MIDTERM TEST #1 Wednesday,
More informationWinter 2006 FINAL EXAMINATION Auxiliary Gymnasium Tuesday, April 18 7:00pm to 10:00pm
University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Lecture Instructor for L01 and L02: Dr. S. A. Norman Winter 2006 FINAL EXAMINATION Auxiliary Gymnasium
More informationWinter 2012 MID-SESSION TEST Tuesday, March 6 6:30pm to 8:15pm. Please do not write your U of C ID number on this cover page.
University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Lecture Instructors: S. A. Norman and N. R. Bartley Winter 2012 MID-SESSION TEST Tuesday, March 6
More informationWinter 2003 MID-SESSION TEST Monday, March 10 6:30 to 8:00pm
University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Instructors: Dr. S. A. Norman (L01) and Dr. S. Yanushkevich (L02) Winter 2003 MID-SESSION TEST Monday,
More informationWinter 2009 FINAL EXAMINATION Location: Engineering A Block, Room 201 Saturday, April 25 noon to 3:00pm
University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Lecture Instructors: S. A. Norman (L01), N. R. Bartley (L02) Winter 2009 FINAL EXAMINATION Location:
More informationMidterm Examination # 2 Wednesday, March 18, Duration of examination: 75 minutes STUDENT NAME: STUDENT ID NUMBER:
Page 1 of 8 School of Computer Science 60-141-01 Introduction to Algorithms and Programming Winter 2015 Midterm Examination # 2 Wednesday, March 18, 2015 ANSWERS Duration of examination: 75 minutes STUDENT
More informationENCM 339 Fall 2017 Tutorial for Week 8
ENCM 339 Fall 2017 Tutorial for Week 8 for section T01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary 2 November, 2017 ENCM 339 T01 Tutorial
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 informationSlide Set 4. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng
Slide Set 4 for ENCM 339 Fall 2017 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2017 ENCM 339 Fall 2017 Section 01
More informationSlide Set 15 (Complete)
Slide Set 15 (Complete) for ENCM 339 Fall 2017 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary November 2017 ENCM 339 Fall 2017
More informationSlide Set 3. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng
Slide Set 3 for ENCM 339 Fall 2017 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2017 ENCM 339 Fall 2017 Section 01
More informationSignature: ECE 551 Midterm Exam
Name: ECE 551 Midterm Exam NetID: There are 7 questions, with the point values as shown below. You have 75 minutes with a total of 75 points. Pace yourself accordingly. This exam must be individual work.
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 informationUniversity of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Instructor: Steve Norman
page of 9 University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Instructor: Steve Norman Winter 26 FINAL EXAMINATION (with corrections) Location: ICT 2
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 informationSlide Set 2. for ENCM 335 in Fall Steve Norman, PhD, PEng
Slide Set 2 for ENCM 335 in Fall 2018 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2018 ENCM 335 Fall 2018 Slide Set 2 slide
More informationECE551 Midterm Version 1
Name: ECE551 Midterm Version 1 NetID: There are 7 questions, with the point values as shown below. You have 75 minutes with a total of 75 points. Pace yourself accordingly. This exam must be individual
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 informationSlide Set 4. for ENCM 335 in Fall Steve Norman, PhD, PEng
Slide Set 4 for ENCM 335 in Fall 2018 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2018 ENCM 335 Fall 2018 Slide Set 4 slide
More informationMidterm Examination # 2 Wednesday, March 19, Duration of examination: 75 minutes STUDENT NAME: STUDENT ID NUMBER:
Page 1 of 7 School of Computer Science 60-141-01 Introduction to Algorithms and Programming Winter 2014 Midterm Examination # 2 Wednesday, March 19, 2014 ANSWERS Duration of examination: 75 minutes STUDENT
More informationMARKS: Q1 /20 /15 /15 /15 / 5 /30 TOTAL: /100
FINAL EXAMINATION INTRODUCTION TO ALGORITHMS AND PROGRAMMING II 03-60-141-01 U N I V E R S I T Y O F W I N D S O R S C H O O L O F C O M P U T E R S C I E N C E Winter 2014 Last Name: First Name: Student
More informationSlide Set 9. for ENCM 335 in Fall Steve Norman, PhD, PEng
Slide Set 9 for ENCM 335 in Fall 2018 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary October 2018 ENCM 335 Fall 2018 Slide Set 9 slide 2/32
More informationEXAMINATION REGULATIONS and REFERENCE MATERIAL for ENCM 339 Fall 2017 Section 01 Final Examination
EXAMINATION REGULATIONS and REFERENCE MATERIAL for ENCM 339 Fall 2017 Section 01 Final Examination The following regulations are taken from the front cover of a University of Calgary examination answer
More informationCOP 3223 Introduction to Programming with C - Study Union - Fall 2017
COP 3223 Introduction to Programming with C - Study Union - Fall 2017 Chris Marsh and Matthew Villegas Contents 1 Code Tracing 2 2 Pass by Value Functions 4 3 Statically Allocated Arrays 5 3.1 One Dimensional.................................
More informationWinter 2002 FINAL EXAMINATION
University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Instructors: Dr. S. A. Norman (L01) and Dr. S. Yanushkevich (L02) Note for Winter 2005 students Winter
More informationFinal CSE 131B Spring 2005
Login name Signature Name Student ID Final CSE 131B Spring 2005 Page 1 Page 2 Page 3 Page 4 Page 5 Page 6 Page 7 Page 8 (27 points) (24 points) (32 points) (24 points) (32 points) (26 points) (31 points)
More informationECE551 Midterm Version 2
Name: ECE551 Midterm Version 2 NetID: There are 7 questions, with the point values as shown below. You have 75 minutes with a total of 75 points. Pace yourself accordingly. This exam must be individual
More informationCSE 303 Midterm Exam
CSE 303 Midterm Exam October 29, 2008 Name Sample Solution The exam is closed book, except that you may have a single page of hand written notes for reference. If you don t remember the details of how
More informationPDS Class Test 2. Room Sections No of students
PDS Class Test 2 Date: October 27, 2016 Time: 7pm to 8pm Marks: 20 (Weightage 50%) Room Sections No of students V1 Section 8 (All) Section 9 (AE,AG,BT,CE, CH,CS,CY,EC,EE,EX) V2 Section 9 (Rest, if not
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 informationSlide Set 3. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary
Slide Set 3 for ENCM 339 Fall 2016 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary September 2016 ENCM 339 Fall 2016 Slide Set 3 slide 2/46
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 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 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 informationENCM 339 Fall 2017 Lecture Section 01 Lab 3 for the Week of October 2
page 1 of 11 ENCM 339 Fall 2017 Lecture Section 01 Lab 3 for the Week of October 2 Steve Norman Department of Electrical & Computer Engineering University of Calgary September 2017 Lab instructions and
More informationSubject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100
Code: DC-05 Subject: PROBLEM SOLVING THROUGH C Time: 3 Hours Max. Marks: 100 NOTE: There are 11 Questions in all. Question 1 is compulsory and carries 16 marks. Answer to Q. 1. must be written in the space
More informationENCM 335 Fall 2018 Tutorial for Week 13
ENCM 335 Fall 2018 Tutorial for Week 13 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary 06 December, 2018 ENCM 335 Tutorial 06 Dec 2018 slide
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 informationSlide Set 6. for ENCM 339 Fall 2017 Section 01. Steve Norman, PhD, PEng
Slide Set 6 for ENCM 339 Fall 2017 Section 01 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary October 2017 ENCM 339 Fall 2017 Section 01 Slide
More informationtoday cs3157-fall2002-sklar-lect05 1
today homework #1 due on monday sep 23, 6am some miscellaneous topics: logical operators random numbers character handling functions FILE I/O strings arrays pointers cs3157-fall2002-sklar-lect05 1 logical
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 informationRecursion. Data and File Structures Laboratory. DFS Lab (ISI) Recursion 1 / 27
Recursion Data and File Structures Laboratory http://www.isical.ac.in/~dfslab/2017/index.html DFS Lab (ISI) Recursion 1 / 27 Definition A recursive function is a function that calls itself. The task should
More informationPRINCIPLES OF OPERATING SYSTEMS
PRINCIPLES OF OPERATING SYSTEMS Tutorial-1&2: C Review CPSC 457, Spring 2015 May 20-21, 2015 Department of Computer Science, University of Calgary Connecting to your VM Open a terminal (in your linux machine)
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 informationLanguage Design COMS W4115. Prof. Stephen A. Edwards Spring 2003 Columbia University Department of Computer Science
Language Design COMS W4115 Prof. Stephen A. Edwards Spring 2003 Columbia University Department of Computer Science Language Design Issues Syntax: how programs look Names and reserved words Instruction
More informationC mini reference. 5 Binary numbers 12
C mini reference Contents 1 Input/Output: stdio.h 2 1.1 int printf ( const char * format,... );......................... 2 1.2 int scanf ( const char * format,... );.......................... 2 1.3 char
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 informationCommon Misunderstandings from Exam 1 Material
Common Misunderstandings from Exam 1 Material Kyle Dewey Stack and Heap Allocation with Pointers char c = c ; char* p1 = malloc(sizeof(char)); char** p2 = &p1; Where is c allocated? Where is p1 itself
More informationECE551 Midterm. There are 7 questions, with the point values as shown below. You have 75 minutes with a total of 75 points. Pace yourself accordingly.
Name: ECE551 Midterm NetID: There are 7 questions, with the point values as shown below. You have 75 minutes with a total of 75 points. Pace yourself accordingly. This exam must be individual work. You
More informationSchool of Computer Science Introduction to Algorithms and Programming Winter Midterm Examination # 1 Wednesday, February 11, 2015
Page 1 of 8 School of Computer Science 60-141-01 Introduction to Algorithms and Programming Winter 2015 Midterm Examination # 1 Wednesday, February 11, 2015 Marking Exemplar Duration of examination: 75
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 informationWhy arrays? To group distinct variables of the same type under a single name.
Lesson #7 Arrays Why arrays? To group distinct variables of the same type under a single name. Suppose you need 100 temperatures from 100 different weather stations: A simple (but time consuming) solution
More informationFirst of all, it is a variable, just like other variables you studied
Pointers: Basics What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the address (rather than the value)
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 informationCS150 - Sample Final
CS150 - Sample Final Name: Honor code: You may use the following material on this exam: The final exam cheat sheet which I have provided The matlab basics handout (without any additional notes) Up to two
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 Final Examination December 21, 2015 9:30 a.m. 12:00 p.m. (150 minutes) Examiners: J. Anderson, B. Li, J. Rose
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 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 informationLanguage Design COMS W4115. Prof. Stephen A. Edwards Fall 2006 Columbia University Department of Computer Science
Language Design COMS W4115 Katsushika Hokusai, In the Hollow of a Wave off the Coast at Kanagawa, 1827 Prof. Stephen A. Edwards Fall 2006 Columbia University Department of Computer Science Language Design
More informationCS113: Lecture 9. Topics: Dynamic Allocation. Dynamic Data Structures
CS113: Lecture 9 Topics: Dynamic Allocation Dynamic Data Structures 1 What s wrong with this? char *big_array( char fill ) { char a[1000]; int i; for( i = 0; i < 1000; i++ ) a[i] = fill; return a; void
More informationENCM 339 Fall 2017 Lecture Section 01 Lab 9 for the Week of November 20
page 1 of 9 ENCM 339 Fall 2017 Lecture Section 01 Lab 9 for the Week of November 20 Steve Norman Department of Electrical & Computer Engineering University of Calgary November 2017 Lab instructions and
More informationCS113: Lecture 9. Topics: Dynamic Allocation. Dynamic Data Structures
CS113: Lecture 9 Topics: Dynamic Allocation Dynamic Data Structures 1 What s wrong with this? char *big_array( char fill ) { char a[1000]; int i; for( i = 0; i < 1000; i++ ) a[i] = fill; return a; void
More informationContents of Lecture 3
Contents of Lecture 3 Repetition of matrices double a[3][4]; double* b; double** c; Terminology Linkage Types Conversions Jonas Skeppstedt (js@cs.lth.se) Lecture 3 2014 1 / 33 A global matrix: double a[3][4]
More informationECE 2035 Programming HW/SW Systems Spring problems, 5 pages Exam Three 8 April Your Name (please print clearly)
Your Name (please print clearly) This exam will be conducted according to the Georgia Tech Honor Code. I pledge to neither give nor receive unauthorized assistance on this exam and to abide by all provisions
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 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 informationC Language Part 2 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee
C Language Part 2 (Minor modifications by the instructor) 1 Scope Rules A variable declared inside a function is a local variable Each local variable in a function comes into existence when the function
More informationFinal Intro to C Review
Final Exam Content: Final Intro to C Review - Pass by reference Functions - General Syntax - Structures - Recursion(maybe?) - Programming by nature is cumulative so any past material is up for grabs as
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 informationCSC209H Lecture 4. Dan Zingaro. January 28, 2015
CSC209H Lecture 4 Dan Zingaro January 28, 2015 Strings (King Ch 13) String literals are enclosed in double quotes A string literal of n characters is represented as a n+1-character char array C adds a
More informationIntermediate Programming, Spring 2017*
600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general
More informationWarmup January 9th, What is the value of the following C expression? 8*9 % 10/ 2
Warmup January 9th, 2018 What is the value of the following C expression? 8*9 % 10/ 2 Warmup January 11th, 2018 What is the value of the following C expression? ( -42 3!= 3) && ( -3 < -2 < -1) Warmup January
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 informationUniversity of California San Diego Department of Electrical and Computer Engineering. ECE 15 Final Exam
University of California San Diego Department of Electrical and Computer Engineering ECE 15 Final Exam Tuesday, March 21, 2017 3:00 p.m. 6:00 p.m. Room 109, Pepper Canyon Hall Name Class Account: ee15w
More informationPointers and File Handling
1 Pointers and File Handling From variables to their addresses Pallab Dasgupta Professor, Dept. of Computer Sc & Engg INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR 2 Basics of Pointers INDIAN INSTITUTE OF TECHNOLOGY
More informationAdvanced Pointer Topics
Advanced Pointer Topics Pointers to Pointers A pointer variable is a variable that takes some memory address as its value. Therefore, you can have another pointer pointing to it. int x; int * px; int **
More informationHigh Performance Programming Programming in C part 1
High Performance Programming Programming in C part 1 Anastasia Kruchinina Uppsala University, Sweden April 18, 2017 HPP 1 / 53 C is designed on a way to provide a full control of the computer. C is the
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 informationECE264 Summer 2013 Exam 1, June 20, 2013
ECE26 Summer 2013 Exam 1, June 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. I
More informationThe output will be: marks all or nothing. 1 #include <stdio.h> 2 main() { 3 int i; int j; 4 int *p; int *q; 6 p = &i; 7 q = &j; 8 i = 1;
p. 2 of 9 Q1. [5 marks] The following program compiles and runs with no problems. Indicate what the output of the program is going to be (no explanation necessary). 1 #include 2 main() { 3 int
More informationCIS 2107 Computer Systems and Low-Level Programming Fall 2011 Midterm
Fall 2011 Name: Page Points Score 1 5 2 10 3 10 4 7 5 8 6 15 7 4 8 7 9 16 10 18 Total: 100 Instructions The exam is closed book, closed notes. You may not use a calculator, cell phone, etc. For each of
More informationCSE351 Winter 2016, Final Examination March 16, 2016
CSE351 Winter 2016, Final Examination March 16, 2016 Please do not turn the page until 2:30. Rules: The exam is closed-book, closed-note, etc. Please stop promptly at 4:20. There are 125 (not 100) points,
More informationThe C Language Reference Manual
The C Language Reference Manual Stephen A. Edwards Columbia University Summer 2014 Katsushika Hokusai, In the Hollow of a Wave off the Coast at Kanagawa, 1827 Part I The History of C C History Developed
More information15110 PRINCIPLES OF COMPUTING SAMPLE EXAM 2
15110 PRINCIPLES OF COMPUTING SAMPLE EXAM 2 Name Section Directions: Answer each question neatly in the space provided. Please read each question carefully. You have 50 minutes for this exam. No electronic
More informationCS201 Some Important Definitions
CS201 Some Important Definitions For Viva Preparation 1. What is a program? A program is a precise sequence of steps to solve a particular problem. 2. What is a class? We write a C++ program using data
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 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 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 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 information16.216: ECE Application Programming Spring 2015 Exam 3 Solution
16.216: ECE Application Programming Spring 2015 Exam 3 Solution 1. (20 points, 4 points per part) Multiple choice For each of the multiple choice questions below, clearly indicate your response by circling
More informationFundamentals of Programming Session 8
Fundamentals of Programming Session 8 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2013 These slides have been created using Deitel s slides Sharif University of Technology Outlines
More informationarrays and strings week 3 Ritsumeikan University College of Information Science and Engineering Ian Piumarta 1 / 22 imperative programming review
of char imperative week 3 and Ritsumeikan University College of Information Science and Engineering Ian Piumarta 1 / 22 : miscellaneous of char several library functions are have put or get in their name
More informationUniversity of Waterloo Department of Electrical and Computer Engineering ECE 250 Data Structures and Algorithms. Final Examination T09:00
University of Waterloo Department of Electrical and Computer Engineering ECE 250 Data Structures and Algorithms Instructor: Douglas Wilhelm Harder Time: 2.5 hours Aides: none 18 pages Final Examination
More information