CSE 701 Practice Test 1: Chapters 1-3 McMaster University, Fall 2024 |
Table of contents |
Instructions ^You have 1 hour to solve the exam. There are 8 questions in total, and the points sum up to 100. The only allowed material is the course lecture notes. You are not allowed to write anything on the printed notes or modify them in any way before or after printing, but you can use a highlighter. Computers, phones, tablets, and other digital devices cannot be used during the exam. |
Question 1 (10 points) ^What does it mean for a language to be "higher-level" than another language? |
Question 2 (12 points) ^The following C program has 4 errors. Find the errors and explain why each of them is an error. Rewrite the program without these errors, so that it works correctly and prints out the expected output. |
Question 3 (12 points) ^The following C program has 4 errors. Find the errors and explain why each of them is an error. Rewrite the program without these errors, so that it works correctly and prints out the expected output. |
Question 4 (12 points) ^The following program is not portable, meaning it may produce different outputs on different operating systems. Explain why that is. Fix it so that it is portable and produces the same output on all operating systems. |
Question 5 (12 points) ^What will be the output of the following program? |
Question 6 (12 points) ^What will be the output of the following program? |
Question 7 (15 points) ^Write a function Note that you do not need to write a full program, just one function. However, the function must be complete and correct, such that if you enter it as-is into a program in VS Code, it will compile and run successfully without any errors or warnings (with all the warning flags recommended in this course enabled) and produce the expected output for any reasonable input. Make sure that the function uses portable integer types! |
Question 8 (15 points) ^Write a program that finds the largest and smallest elements of the array This must be a complete and correct program, with all the header files, |