Practice Exam ---------------------------------------- ** On paper portion. Last Name: First Name: Section (start time of your class): 1) Do the conversion. Show your work. No credit if you don't show some work. 1a) Convert 125 decimal to binary. 1b) Convert 125 decimal to hex. 1c) Convert 1001101 binary to hex. 1d) Convert 1001101 binary to decimal. 2) The ASCII value for 'a' is 97. What is the ASCII value for 'd'? 3) How many bits does it take to represent the number 260? Show your work. No credit if no work/justification given. 4) Be the computer. For each, keep track of the values of all the variables as the code runs - as we did in class. 4a) basic arithmetic. // code int x = 1, y = 2; float z = x / y; x = x + 3 * y; y = y * 2 + y; y = (x+y) % 3; z = (z + 1) / 2.0; // variable values. // // x: // // y: // // z: // 4b) Boolean logic, conditionals. // code int x = 42; char ch = 'a'; if (x > 40 && x < 30) { if (ch == 'b') x = x / 2; else x = x - 10; ch = ch + 3; } else { if (ch == 'c') x = x + 10; else x = x * 2; ch = ch + 1; } x = (x < 50 && x > 30) || (ch == 'a' || ch == 'b'); // variable values. // // x: // // ch: // 4c) Loops. // code int i; int total=0; for(i=0; i < 10; i += 2) { total = total + i; } // variable values. // // i: // // total: // ---------------------------------------- ** On computer portion. NOTE: the files mentioned below don't actually exist here right now. But this is an example of the kinds of questions that will be on the test. 1) In this directory, create a file called exam1Answers.txt. In the file, put your name at the top. Save the file. 2) Compile the file convertExam.cpp that is in this directory. Compile the file so the executable program is called conv. Run the conv program and copy/paste what is printed into the exam1Answers.txt file as the answer to question 2. 3) The file passwordExam.cpp in this directory asks the user to enter an integer code. It checks that the code is correct before printing that the password has been entered correctly. Modify the program so that it keeps track of how many times the user has entered an incorrect password, and print a message each time telling them how many times they have tried so far. 4) The file addExam.cpp in this directory is supposed to add up the odd numbers between 1 and 999. It has a syntax error right now, so it won't compile. Fix the syntax error, and compile the program so the executable program is called add. !!!!!IMPORTANT!!!! When you are done with the exame, run the program finishExam that is in this directory. You will receive 0 credit for the exam if you do not run this file.