0% found this document useful (0 votes)
22 views20 pages

C++ Theory Papers

C++ and Database notes and question paper

Uploaded by

Josphat Mpofu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
22 views20 pages

C++ Theory Papers

C++ and Database notes and question paper

Uploaded by

Josphat Mpofu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 20
ZIMBABWE MINISTRY OF HIGHER AND ‘TERTIARY EDUCATION, SCIENCE AND TECHNOLOGY DEVELOPMENT HIGHER EDUCATION EXAMINATIONS COUNCIL (HEXCO) NATIONAL CERTIFICATE “ IN INFORMATION TECHNOLOGY SUBJECT: Programming Using C++ PAPER NO: 317/18/S02A (Theory) DURATION: 3 Hours MARCH/APRIL EXAMINATION REQUIREMENTS Answer Booklet INSTRUCTIONS TO CANDIDATE Answer all questions This paper consists of 3 printed pages. PAP! ER NO: 17/18/8094 PROGRAMMING USING C++ (THEORY, QUESTION 1 8) Giving reasons, indicat invalid identifier: i) class private false college stud_Id le whether cach of the following is a valid or (10 marks) b) Write Pseudocode to determi whether it isa pass or a fail two marks. QUESTION 2 a) Evaluate the following expressions given that a = 10 and b = 5 i) at=b; ii) c= (a=65) Cout <<"Age is greater than or equal to 65° < 0) { cout<=1) if (c % 2==0) , cout <48:8(7<=8)II1(4) vy) (‘A°%2)==0 (10 marks) b) Distinguish between break and continue in C++ loops and use program segments to illustrate your answer. (8 marks) ¢) Explain the purpose of the “default” keyword in a switch statement. (2 marks) QUESTION 3 a) Explain the two (2) ways used to define member functions in C++ programming (4 marks) b) Differentiate a constructor from a destructor (4 marks) (10 marks) ¢) Explain any five (5) data types used in C++ ‘ing array a, Y declaration int numArray| | = (16, 4, 29, 42, -8, 6, b) Write Program Statements to ) Dis Play th © Sum of all the odd elements in the array (4 marks) i) Pin Pons d the largest element in the array (3 mark: - marks) Play the elements of the array starting with the last one iv) Set the fit = fifth element of the array to 34, (1 mark) Distinguish between the following )) Void function and value returning function ii) Pass by value and pass by address ii) Formal parameters and arguments iv) Global scope and local scope Function prototype and function definition (10 marks) v QUESTION 5 a) b) ¢) Declare a structure to hold the following product details: product number, product name and unit price for twenty different products in stock. (5 marks) Write a C++ code segment to display the details of all the products in (6 marks) stock. Determine the default file opening mode(s) for each of the following file classes i) ofstream ii) ifstream (6 marks) iii) fstream Determine the effect of the following C++ program segment. ofstream thisfile; thisfile.open(“we.txt’, ios:: outlios:: applios::binary); (4 marks) we / km, zImnabwe INNOUNISTRY OF HIGHER AND TERTIARY EDUCATION, VATION, SCIENCE AND TECHNOLOGY DEVELOPMENT | HIGHER EDUCATION EXAMINATIONS. COUNCIL (HEXCO) NATIONAL CERTIFICATE IN INFORMATION TECHNOLOGY SUBJECT: Programming using C++ (Theory) DURATION: 3 hours [ MARCH/APRIL 2022 EXAMINATION ] REQUIREMENTS PAPER NO: 317/18/S02A Answer booklet INSTRUCTIONS TO CANDIDATE Answer all questions. This paper consists of 5 printed pages. PAPER NO: 317/18/802 PROGRAMMING USING C+ THEORY QUESTION 1 Flow Chart BMI=weight/(height)? Uinderwei Display “Normal weight” Display “Overweight” PAPER No LIBLSO2A ~ PROGRAMMING USING CH TH R a) Given the above flow chart, write @ corresponding algorithm, (10 marks) b) Explain the following OOP terms: inictor Goan i) Data abs marke) ©) Differentiate between a run time and a compile time error, giving examples of cach. (4 marks) QUESTION 2 a) Give an cxample for each of the following components of a C+ program: Single line comment (2 marks) Pre-processor directive (2 marks) Global declaration (2 marks} C++ statement (2 marks) Local variable (2 marks) Convert the following mathematical expressions to valid C++ expressions: i) m=¥ety (3 marks) bet (2 marks) ae oy QUESTION 3 a) Determine the values of x, y and z after execution of the program segment. int x=10, y=12, 2= switch (x) { case 9: case 10: case 1 default: (6 marks) ¢) 302A = PROGRAMMING USING c+ THEORY Aments explain the following control structures: i) While loop ii) For loop (3 marks) iii) If... else statement (3 marks) (3 marks) int array [5]=(13, 20, 64, 50, 29); Write code segment to perform the following: QUESTION 4 a) b) i) Subtract first element from last clement. ; - (2 ii) Find the average of clements in the array. e mare) iii) Display the array clements in reverse order, (3 marks) Given the following declaration: struct addr {int houseno; char strect [30}; char city [20]; B struct student { ° int studentno; char name [30]; addr address; } ITStudents [5]; (10 marks) Write a code segment to input details of five students. Write a function that accepts two integer parameters using the pass by reference method. ‘The function calculates and returns the sum of the two (8 marks) integers. Write a statement to display the value returned by the function in (b). (2 marks) A ee PAPER NO: 317/18/S02A ~ PROGRAMMING | (QUESTION 5 a) Explain the following methods as they are used in file processing: i) Is_open () (2 marks) i) eof () (2 marks) (2 marks) (2 marks) (2 marks) iii) getline () iv) close () v) open () class tructure of a C+t {10 marks) b) With the aid of an example describe the general s' wih definition. ZIMBABWE MINISTRY OF HIGHER AND TERTIARY EDUCATION, INNOVATION, SCIENCE AND TECHNOLOGY DEVELOPMENT HIGHER EDUCATION EXAMINATIONS COUNCIL (HEXCO) NATIONAL CERTIFICATE IN INFORMATION TECHNOLOGY SUBJECT: Programming Using C++ (Theory) PAPER NO: 317/18/S02A DURATION: 3 Hours REQUIREMENTS Answer Booklet INSTRUCTIONS TO CANDIDATES Answer all questions This paper consists of 4 printed pages. PAPER NO: 317/18/802A - PROGRAMMING USING C++ (THEORY) QUESTION 1. Outline any five (5) differences between object oriented programming a) (10 marks) (OOP) and procedural oriental programming (POP). Draw aflowchart for a program to calculate and display the sum of all ») integers from 1 to 30. (10 marks) UESTION 2 a) Complete the following table Escape Character Carriage return (10 marks) b) Indicate the most appropriate data type for each of the following variables i) Age ii) Married iii) Initial iv) Price v) Name (6 marks) QUESTION 3 Write code segments to illustrate the use of the following control structures a) If statement b) While loop c) — do...while loop d) for loop e) switch case (10 marks) PAPER NO: 317/18/S02A = PROGRAMMING US! ING C++ (THEORY) QUESTION 4 Given the following code segment: a) int mum[]= {10, 20, 30, 40, 50}; int t= 2 cout<

You might also like