Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Data Structures and Algorithms – Midterm Examination 15 March 2020

University of Science & Technology Level : 2nd Level IT/CN


Ibb Branch Semester : 2nd 2019/2020
Faculty of Computer Science & Duration : 1 Hour
IT IT and CN Programs Lecturer : Dr. Redhwan Q. Shaddad

Name: ………………………………………………………………………… Major: ………………..

Answer all the following questions:

Q1. 10 For stack of characters, define its data type by using the array. Write C++ functions to:
a) Add a new element to the top of the stack.

b) Return the top element of the stack.

c) Remove the top element of the stack.

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

Page 1 of
SAMPLE0
Data Structures and Algorithms – Midterm Examination 15 March 2020
University of Science & Technology Level : 2nd Level IT/CN
Ibb Branch Semester : 2nd 2019/2020
Faculty of Computer Science & Duration : 1 Hour
IT IT and CN Programs Lecturer : Dr. Redhwan Q. Shaddad

Q2. 10 A C++ program defines a record of student (studentType) which has the following
members:
I. name : name of student.
III. average: grade of student.
II. id : identity number of student.
IV. gpa : grade point average of student.
Write C++ code to define:

a) studentType record.

b) readrecord() function to read a record of student (name, id, and average).

c) findgpa() function to find the gpa for specified average.

d) printrecord() function to print a record of student(name, id, average, and gpa).

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

…………………………………………………………………………………………………………………

Good Luck

Page 2 of
SAMPLE0

You might also like