You are on page 1of 4

KOHAT UNIVERSITY OF SCIENCE & TECHNOLOGY

INSTITUTE OF COMPUTING

CS102 – Programming Fundamentals


Course Instructor: Dr. Abdul Shahid

Final Exam (OPEN BOOK)


Program: BSSE Section A Semester: Fall-2020
Max Marks: 50 MaxTime: 24hours

INSTRUCTIONS:

• This is an open book exam. The students can get help/guidance from books, tools, online media, and class notes if any.

• Ensure to write the complete information, i.e. Reg No., Name, Subject, etc, on each and every answer sheet.

• The solution must be purely handwritten, no printed pages will be accepted.

• Use appropriate size papers as answer sheets.

• The exam will start at 9:00 AM sharp and the soft copy of the answer sheets must be submitted within 24hours.

• In the first phase, the students must take scans/pictures of their answer sheets and prepare a PDF file. This file

must be submitted through the KCMS. However, in case of any justified technical issue, the students are allowed

to send their solved papers on the official email of their instructor.

• The handwritten answer sheets must be reached 24hours for the submission of soft copy.

• The students can also submit their answer sheets by hand to the office of their instructor.

• Any late submission of both soft and/or hard copies Or Copying from one another, will not be accepted and the

course instructor will award an ‘I’ grade to such students.

•After receiving the original hand written answer sheets, the instructor will verify as to whether the hard copy is the

same as the submitted soft copy. In case of any variation, the paper will be considered null and void.

• In case of any query, the students can contact their course instructor on 03335491828 or ashahid@kust.edu.pk.

However, only text/WhatsApp messages will be allowed. To ensure transparency, no voice calls are permissible.

Registration Number

Name
Q1. Write a menu driven program which has following options:

1. Factorial
2. Prime or not
3. Odd or even
4. Exit

Once a menu is selected, the appropriate action should be taken and once this action is finished,
the menu should reappear. Unless the user selects the ‘Exit’ option the program should continue
to work.
Note: Consider array of random numbers from user to find Prime Numbers/Odd/Even and user
entered value for factorial.

Q2. Write a program using Switch statement to perform the following functionalities.
1. Press a to call functionOne.
2. Press b to call functionTwo.
3. Press c to call functionThree.
4. Exit as any other key pressed.(default)

functionOne will return product of all integers entered by user in array of size 8.
functionTwo will perform greatest value in array entered by user.
funtionThree will calculate lowest value in an array entered by user.

Q3. A person has 5 electronic stores in a Kohat city. He records the daily sale by each store at the end of each
day, for seven days of a week (Mondy, Tuesday,…, Sunday). Thus, at the end of a week he has the following
data:
[0] [1] [2] [3] [4]
[0] 4000 6000 10000 11000 3000
[1] 9000 8000 19000 7000 9000

[6] 15000 3000 11000 2000 2000

Write a program that asks the user to enter daily sale for five stores and record them in an array.
The program should then display a bar graph comparing each store’s sales for all days of a week.
Create each bar in the bar graph by displaying a row of asterisks. Each asterisk should represent
Rs.1000 of sales. The program also calculates the total sale each day, and total sale of the week.
Here is an example of the program s output.
Enter day 1 sales for store 1: 4000 [Enter]
Enter day 1 sales for store 2: 6000 [Enter]
Enter day 1 sales for store 3: 10000 [Enter]
Enter day 1 sales for store 4: 11000 [Enter]
Enter day 1 sales for store 5: 3000 [Enter]

Enter day 2 sales for store 1: 9000 [Enter]


Enter day 2 sales for store 2: 8000 [Enter]
Enter day 2 sales for store 3: 19000 [Enter]
Enter day 2 sales for store 4: 7000 [Enter]
Enter day 2 sales for store 5: 9000 [Enter]
…(and so on.)
Weekly Sale
Monday: Total Sale: 34,000/-
Store 1: **** (4000)
Store 2: ****** (6000)
Store 3: ********** (10000)
Store 4: *********** (11000)
Store 5: *** (3000)
Tuesday: Total Sale: 52,000/-
Store 1: ********* (9000)
Store 2: ******** (8000)
Store 3: ******************* (19000)
Store 4: ******* (7000)
Store 5: ********* (9000)
…(and so on.)
Total Sale This Week: 123,456/-

Q4. Write a program named lower-half which takes input for a two dimensional array of 5 rows and
5 columns and prints the lower half of the array.
For example if user enters the following numbers:
34915, 10501, 25781, 71531, 23150
Then the output is:
5, 01, 781, 1531, 23150
Q5. Suppose a 2d array filled with elements as shown below.
Before After

1 2 3 4 9 10 11 12
5 6 7 8 5 6 7 8
9 10 11 12 1 2 3 4

Reverse order of the columns elements and display it.

You might also like