Programming Fundamentals, Past Papers

Programming Fundamentals BSCS 1st Term 2016 Past Paper UOS

A clear scanned exam paper from University of Sargodha dated 2016 for BS 1st Term Computer Science students.

University of Sargodha
BS 1st Term Examination 2016

Subject: Computer Science
Paper: Programming Fundamental (CMP-2122)

Time Allowed: 2:30 Hours
Maximum Marks: 60

Objective Part (Compulsory)

Q.1. Write short answers of the following questions in 2-3 lines only (12*2=24):

i. Evaluate the expression 50 / (6 + (8 – 4) * 2) + 15
ii. Write the name of two escape sequences and their functions.
iii. Give one example of implicit and explicit type casting?
iv. Is the following statement valid or invalid? Give reason whatever the case may be.

v. What does the following code display?

vi. What is scope and life time of a static variable?
vii. Differentiate between while and do while loop?
viii. If ptr is a pointer to int, and i and j are variables of int, what is wrong in the statement?

ix. What is the output?

x. Is statement valid? If it is wrong, write the correct statement.
xi. Declare an int variable and pointer to int in a single statement.
xii. Write a prototype of a function that passes an int value, an int reference and returns a double value.

Subjective Part (4 * 9 = 36)

Q # 2: Write a program that accepts 10 integer values from user in an array and passes array to a function. The function finds the greatest value of the array and returns it to main() that displays the value.

Q # 3: Write a program declares a structure Student with data member rollno and age. Create two variables of structure, accept values and find the average age of these two students and display the average age.

Q # 4: Write a program that displays the sum of first four terms of the series.

Q # 5: Write a program to display the following pattern?

Q # 6: Write a program that accepts a number from user and passes it to a function that determines whether the number is prime or composite. The result is displayed by main function.

Q # 7: Write a program that inputs obtained marks from a student, calculates the percentage (assuming total marks are 1100) and displays the grade. The grade should be calculated according to the following criterion.