Spring 2024 Midterm
Page 1
Midterm Exam Spring 2024
ESE 124
Instructor: Dr. Alex Doboli
1.
(40 pts) The symmetric difference of two sets is the set of elements which are in either
one of the two sets but not in both. For example, given sets A = {1, 2, 3} and B = {2, 3, 4}, then
the symmetric difference is the set {1, 4} (The value 1 is in set A but not in set B, and the value 4
is in set B but not in set A).
Devise a C program that reads the set A from file In1.txt and the set B from file In2.txt, and then
writes the symmetric difference of set A and set B in the output file Out1.txt.
Question 2
2. (30 points) Devise a C program to compute the value of the following function described
by its Taylor series approximation:
sinh(z)=z + z3/3! + z5/5! + z7/7! + ...
The value of the parameter z is read from the keyboard, and the function value is displayed on
the computer screen. New terms are added to the Taylor series until the value of a new term is
below the value of the variable epsilon. The value of the variable epsilon is also input from the
keyboard.
3.
(30 points) Devise a C program that reads strings from an input file, and then creates an
output file that includes only the input strings that contain a certain substring. The substring is
read from the keyboard.
Example:
Input file: This is the test string
Substring: st
Output file: test string