Programming Fundamentals BSSE 1st Term 2015 Past Paper UOS

University of Sargodha
BS 1st Term Examination 2015
Subject: Software Engineering
Paper: Programming Fundamentals (CMP-2122)
Time Allowed: 2:30 Hours
Maximum Marks: 60
Objective Part (Compulsory)
Note: Attempt all questions, each question carries equal marks (2*12=24)
- What is a variable? How to declare a legal variable in C program?
- What is the difference between high level and machine level language?
- Differentiate for and while loop?
- How many main () functions are defined in a C program, justify your answer?
- Evaluate the expression, y = 6 / 2 * 2 + 3 * 5 + 7;
- If x is a variable in C, then what is the difference b/w x++ & ++x?
- What is syntax error?
- Difference b/w Prototype and definition of a function.
- Why break statement is used in switch structure?
- Why a programmer use fopen() and fclose() function in C program?
- What is the structure? Define syntax of structure.
- What is a pointer? Write an example of initialization of a pointer?
Subjective: (4*9=36)
Note: Attempt any four questions
Q2. Write a program to calculate the net pay of an employee. Input the basic pay, pass the basic pay to the user defines function paycalculate(), calculate the net pay and return to main function. Calculate the net pay of an employee:
- House rent is 43% of the basic.
- Medical allowance is 3% of basic pay if basic pay is greater than Rs.7000/-. It is 5% of basic pay if the basic pay is less or equal than Rs.7000/-.
- Conveyance allowance is Rs.96/-. If basic pay is less than or equal Rs.7000/-. It is Rs.193/- if the basic pay is more than Rs.7000/-.
- Net pay is calculated by adding basic pay, medical allowance, conveyance allowance and house rent.
Q3. Write a program that displays the following output using nested loop.
Q4. Assuming that a text file named FIRST.txt contains some text written into it, write a function named copyupper(), that reads the file FIRST.txt and creates a new file named SECOND.txt contains all words from the file FIRST.txt in uppercase. (Hint: toupper() function converts the lowercase letter in C to the corresponding uppercase letter).
Q5. Write a program that takes 10 elements of array from the user. Find Maximum element from the array then Swap the Maximum element with last element of array. Display array before and after swapping.
Q6. Write a program that accepts an integer number from the user. Calculate and display its factorial by using a recursive function.
Q7. Write a C program that creates a structure Complex which represents fields by integers real and imaginary. Program allows the user to enter the real and imaginary parts of two complex numbers. This program calculates the sum of two complex numbers which will be entered by the user. Program will add real parts and imaginary parts of complex numbers and prints the sum of complex number on the screen.