Summer 2024 Final

Back to the exam archive

Page 1

                                                    Final Exam
                                     ESE 124 (Programming Fundamentals)
                                                   Summer 2024
Rules:
- Exam is closed-book/closed-note; use one 8.5x11in sheet (both sides).
- You can tear pages; write your name on each page.
- Points breakdown: Coding Logic (45%), Problem-solving (40%), Code
Documentation (15%).
Advice:
- Read and understand each question before starting.
- Note down thoughts and steps for partial credit.
- Questions vary in difficulty; skip around if needed.
                    Questions Description
Question 1:
Develop a C program that accomplishes simple text encryption and decryption by shifting each letter to
the next in sequence, and others remain. For example, 'A' would be transformed into 'B,' 'J' into 'H,' ‘z’
into ‘a’ and so forth. The program should be designed to read an input file, perform text encryption,
decrypt the text back to its original form:
// Function prototypes
char* encrypt(char* input);
char* decrypt(char* input);
         Input:
         xyz aaB NIb 12Yafh
         12cbsz @ yza 123azy
         Encrypted result:
         yza bbC OJc 12Zbgi
         12dcta @ zab 123baz
         Decrypted result:
         xyz aaB NIb 12Yafh
         12cbsz @ yza 123azy
Question 2:
Implement a FSM with the following functionality: Read in one binary value (1 or 0) at a time. When the
user inputs the sequence 1101 outputs “ON”, when they input the sequence 110 output “STANDBY” and
for any other case output “OFF”.
Question 3:
Write a C program to find the position of the last person who will receive the cake. There are n people
standing in a circle. Starting from a chosen person, count k people (wrapping around if necessary), and
eliminate the kth person. Repeat this process until only one person remains. The program should output
the position of this last remaining person.
Both n (total number of people) and k (counting step) are greater than 1, and k can be greater than n.

Page 2

Requirements:
    ●
         Implement a circular queue (as ADT) to simulate the elimination process.
    ●
         Write a function to output the initial position of the last person remaining.
    ●
         Ensure your program handles the circular nature of the problem and correctly simulates the
         elimination process.
©