| CSE 701 Practice Exam 1: Chapters 1-3 McMaster University, Fall 2026 |
Table of contents |
Notes about the practice exam ^This practice exam is in the same format, length, and difficulty level as the real exam, and covers the same material. You are prepared for the real exam if you can solve all the questions in this practice exam on your own, with no help from anyone else, human or AI. Tips for effective AI usage: If you just give the exam questions to an LLM and copy its answers, you will never learn how to solve questions yourself, and you will not be prepared for the actual exam. However, once you have solved the practice exam on your own, you can ask an LLM to check your answers and give you feedback, or even generate additional practice exams for you in a similar format. |
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 during the exam is the course lecture notes, in printed form. 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, smart watches, smart glasses, and other digital devices cannot be used during the exam. Any students found using a digital device of any kind during the exam will be charged with academic dishonesty. In addition to ensuring correct C syntax, you must also make sure to closely follow all the programming guidelines and best practices we learned in class, as outlined in the lecture notes - especially those inside the colored warning boxes. |
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 errors. Find all 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 errors. Find all 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 follows all the guidelines below! |
Question 8 (15 points) ^Write a program that finds and prints the largest and smallest elements of the array This must be a complete and correct program, with all the header files, |
Note for the practice test ^The real test will be very similar to the practice test. You will be asked similar questions. It is highly recommended to solve the practice exam on paper, so you can get used to writing code on paper. However, once you are done you should copy your code to a computer and make sure it compiles and all code produces the expected output. Enable all warning flags recommended in this course, and the clang-tidy and cppcheck linters, and ensure that there are no warnings or errors in your code. |
Guidelines ^Here are some important C programming guidelines to follow when solving this practice exam and the real exam:
Please note that these are general guidelines; not all of them apply to this practice exam or to the real exam. This list will not be included in the real exam, but all these guidelines can be found in the lecture notes, which you will have access to during the exam. |