You are on page 1of 4

KING FAISAL UNIVERSITY

College of Computer Sciences and


Information Technology (CCSIT)
Department of Computer Science
Practical Quiz 1
CS120: Fundamentals of Programming
Semester Two: AY 2020 – 2021
Name: ID Number: Date: 21 Feb 2021
Section: 41 Points _____/15

Part 1: DEBUGGING
Instructions (Total Points: 5)
- Use Dev C++ to identify semantic and logical errors in the given program below and correct them.
- Fill-up the table by writing the incorrect program statement at the first column (A) and the correct one at the
second column (B).
- There will be 5 errors in the given program worth 1 point each.
- If there are more than 1 error in a single statement that is considered as 1 answer.

1. #include <iostream>
2. #include <stdio.h>
3. using std:: ;
4. const char = STAR = '*';
5. const int PRIME = 71;

6. int main {
7. int count, sum;
8. double x;
9. count = 1;
10. sum = count + PRIME;
11. x = 25.67;
12. newNum = count * 3;
13. sum + count = sum;
14. sum++;
15. x = x + sum * count;
16. sum += 3;
17. cout << " count = " << count << ", sum = " << sum;
18. cout << ", PRIME = " << Prime << endl;

19. }

Line
S No. A – Incorrect Program statement B. Correct Program statement
No.
1.

2.

3.

4.
pg. 1
CS120 | Practical Final Exam
5.
Part 2: PROGRAMMING (Total Points: 10)
Instructions
- Paste your code for each programming problem in the first row, and program execution screenshot in the
second column.
Q1) Programming Problem 1 - File Name: Riyal_change.cpp (5 pts.)
Write a C++ program to calculate the number of coins of Riyal, Nus, Rubo, Qirish, Halala
will be required for the assigned amount.
Test your solution with sample output:

//Paste your code here

//Paste program execution screenshot here

pg. 2
CS120 | Practical Final Exam

Q2) Programming Problem 2 - File Name: DayofWeek.cpp (5 pts.)


Write a program that will ask the user to enter any value from 1 to 7 that represents a day
in a week. Using switch case statement display the name of the day in words based on the
user input. If the input is other than the below list then provide an appropriate output
message to the user.
If the user enters the following number, the program should display:
Number Display
1 Sunday
2 Monday
3 Tuesday
4 Wednesda
y
5 Thursday
6 Friday
7 Saturday
//Paste your code here

//Paste program execution screenshot here

pg. 3
CS120 | Practical Final Exam

pg. 4

You might also like