Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Capital University of Science and Technology

Department of Computer Science


CS1133 – Introduction to Programming
Final Term Exam (BS CS/SE)
Semester: Fall 2017 Max Marks: 50
Date: Jan 16, 2017 Time: 120 Minutes
Instructors: Dr. Tanvir Afzal(S1), Dr. Azhar Iqbal (S3), Mr. Salman Ahmed (S4),
Mr. Usman Rafiq (S7), Ms. Hajra Klair (S2&S5), Mr. Samir Obaid (S6)
Instructions:
There are FIVE questions in this paper on TWO page. Attempt all questions.

Name: Reg. No.

Part II (Subjective)

Question No. 3. (CLO – 3)

Write a program that allows the user to enter the last names of five candidates in a local election
and the number of votes received by each candidate. The program should then output each
candidate’s name, the number of votes received, and the percentage of the total votes received by
the candidate.
Your program should also output the winner of the election. A sampleoutput is: (10)

Question No. 4. (CLO – 3)

Write a C++ program that declares an array alpha of 50 components of type double. Initialize the
array so that the first 25 components are equal to the square of the index variable, and the last 25
components are equal to three times the index variable. Output the array so that 10 elements per
line are printed. Use pointer notation to solve this question. (10)

Question No. 5. (CLO – 3)

Write the definition of a void function that takes as input two decimal numbers. If the first
number is nonzero, it outputs the second number dividedby the first number; otherwise, it
outputs a message indicating that the secondnumber cannot be divided by the first number
because the first number is 0. (10)

CS1133 – Introduction to Programming Page 1 of 2


Question No. 6. (CLO – 3)

Write a program that reads a 2-D array named MyMatrix of 3 rows and 3 columns from user and
finds the sum of squares of all elements in this array

Question No. 7. (CLO – 3)

Write a program that declares a struct to store the data of a cricket player (player’s name, number
of total runs, and number of total wickets). Declare an array of 10 components to store the data
of 10 cricket players. Your program must read all values (player’s name, number of total runs,
and number of total wickets) for all players from user. Moreover, your program should search a
specific player by name and display his/her total runs and total wickets.

CS1133 – Introduction to Programming Page 2 of 2

You might also like