Final Exam Review


Exam Info

  1. The final exam is accumulative. It covers all chapters we studied throughout this semester.
  2. The final exam consists of two components: programming on computer and paper test.
  3. For the programming on computer part, you will write computer programs to solve two problems. The level of difficulty would be the same as that of most lab and programming assignments you have done. To facilitate the programming test, the instructor may help you fix some "major" syntax or grammar errors if you really need. Students are responsible for program design, coding and testing. For instructor to be able to help other students during the exam, a student should not "demand" too much time from the instructor.
  4. The format of the questions on the paper test part will be similar to that of the homework and previous tests.
  5. The final exam is open-book and note.
  6. The final exam starts at 1:40pm on July 3 (Wednsday) in STC-111 .
  7. Texting and web surfing are not allowed during the exam. Texas Wesleyan's Academic Integrity rules should be followed.

Topics To Be Covered

  1. Functions: basic function structures (function heading/prototype and body). How to define and call to functions.
  2. Loops: while, do-while, and for loops. Be able to use loops to do: read and/or write data from/to files, print out two-dimensional patterns (nested loops), find sum of multiple numbers, and find the largest or smallest number from a list of numbers.
  3. Switch statement. Be familiar with the structure of switch statement and programming techniques using switch such as code sharing by multiple cases (or follow through multiple cases), and default case.
  4. Selection control structures. Boolean expressions (relational and logic), precedences of relational (==, !=, >, <, <=, >=) and logic (&&, ||, !) operators. if statement without else, if-else, and nested if-else.
  5. Input and output: cin, cin.get(char), cin.ignore(int, char), getline(inputstream, string), cout, ifstream, ofstream.
  6. Strings. string data type and its built-in functions such as length, substr, getline and find.
  7. C++ library functions such as sqrt, pow, abs, etc.
  8. Output formatting. setw, setprecision, showpoint, fixed, etc.

Practice Programming Problems

Working on the following problems will help you prepare for the programming part of the final exam.

  1. Write a C++ function to find the solution to a quadratic equation:



    using the formula to find the first of the two roots of the equation:



    The C++ function protype should look like:
    double findSolnQuadraticEqn(double a, double b, double c)
    {
    //a, b, and c are the constants of a quadratic equation
    //This C++ function will check if there is any real solution to the equation. 
    //If yes, it returns the first root. Otherwise, it prints out a message that
    //states there is no real solution and still returns a special number, say, 999.
    }
    
  2. Write a program using nested loop to print out a triangle.
    0 0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0 0
    0 0 0 0 0 0 0
    0 0 0 0 0 0
    0 0 0 0 0
    0 0 0 0
    0 0 0
    0 0
    0 
    
  3. Write a program using loops to print out counting numbers in a triangle pattern with the height chosen by the user (the height < 13).
    Enter the height of the triangle:
    6
      1
      2  3
      4  5  6
      7  8  9 10
     11 12 13 14 15
     16 17 18 19 20 21
    Press any key to continue . . .
    
    Enter the height of the triangle:
    12
      1
      2  3
      4  5  6
      7  8  9 10
     11 12 13 14 15
     16 17 18 19 20 21
     22 23 24 25 26 27 28
     29 30 31 32 33 34 35 36
     37 38 39 40 41 42 43 44 45
     46 47 48 49 50 51 52 53 54 55
     56 57 58 59 60 61 62 63 64 65 66
     67 68 69 70 71 72 73 74 75 76 77 78
    Press any key to continue . . .
    
  4. Write a program using nested loop to print out a $n$ x $n$ matrix with 1s on diagonal and zeros in the rest.
    0 0 0 0 0 0 0 0 0 1
    0 0 0 0 0 0 0 0 1 0
    0 0 0 0 0 0 0 1 0 0
    0 0 0 0 0 0 1 0 0 0
    0 0 0 0 0 1 0 0 0 0
    0 0 0 0 1 0 0 0 0 0
    0 0 0 1 0 0 0 0 0 0
    0 0 1 0 0 0 0 0 0 0
    0 1 0 0 0 0 0 0 0 0
    1 0 0 0 0 0 0 0 0 0
    
  5. Sum all the integer numbers stored in a file without knowing the contents in the file and find the largest integer in the file.
  6. Write a program to generate a sequence of Fibonacci numbers using loop. The sequence pattern is like: 0, 1, 1, 2, 3, 5, 8, 13, 21, ... Also calculate the ratios of two successive numbers. The ratios approach a constant called the Golden Ratio (1.618...) when the sequence is very long.

Study Tips

  1. You are encouraged to review all the homework and previous tests.
  2. Memorizing "facts" from textbook or lectures is necessary to learning, but understanding, critical thinking and problem solving are more important in learning.
  3. Reading textbook definitely helps you understand the subjects.
  4. Group study would work well if you study before participating.
  5. The last but not least. Learn to ask for help whenever you need.
"You can ask a question and look stupid, or not ask a question and be stupid." --Anonymous