Programming Fundamentals MSc IT 1st Term 2016 Past Paper UOS

University of Sargodha
M. Sc. 1st Term Exam 2016
Subject: I.T
Paper: Programming Fundamentals (CMP 2123)
Time Allowed: 2:30 Hour
Maximum Marks: 60
Objective Part (Compulsory)
Q 1. Write short answers of the following in 2-3 lines: (2*12=24)
i. What is preprocessor directive?
ii. Write two rules of declaring a valid variable in C?
iii. Differentiate control controlled and sentinel-controlled repetition?
iv. What is meant by data type?
v. What is the high level language? Give one example.
vi. What are difference b/w pre-increment & post-increment operators?
vii. Describe the importance of default statement in switch statement.
viii. What are syntax errors? Why does it occur?
ix. Define a structure?
x. Define array.
xi. What is a pointer?
xii. In file-processing why a programmer use fgets and fputs functions in a program.
Subjective Part (4*9=36)
Q 2. Write a program to calculate the monthly electricity bill, input the unit from the user. Calculate the bill and display it. Calculate the monthly electricity bill as per the following rule:
- If the unit consumed are equal or less than 300, then the cost is Rs.3/- per unit.
- If units consumed are more than 300, then the cost is Rs.3.54/- per unit and a surcharge of 5% of bill is added
Q 3. Write a program that displays the following output using nested loop:
Q 4. Write a program that initializes an array of ten integers. It inputs an integer (key) from the user and searches the value (key) in the array using sequential search.
Q 5. Write a program that takes an integer number from the user and passes the number to a user defined function. The function displays the table of that number.
Q 6. Write a four function calculator to perform addition, subtraction, multiplication and division that takes two operands and an operator from user. Perform this logic by using switch statement.
Q 7. Write a user-defined function in C to write number 1 to 100 in a text file.