0% found this document useful (0 votes)
3 views78 pages

C Greenbook

The document outlines examination papers for Programming Using C++ for the Higher Education Examinations Council in Zimbabwe. It includes practical programming questions that require candidates to demonstrate their understanding of C++ constructs, functions, and file handling. The questions cover topics such as calculations, data structures, and user input/output, with specific requirements for each task.

Uploaded by

kcharachimwe
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)
3 views78 pages

C Greenbook

The document outlines examination papers for Programming Using C++ for the Higher Education Examinations Council in Zimbabwe. It includes practical programming questions that require candidates to demonstrate their understanding of C++ constructs, functions, and file handling. The questions cover topics such as calculations, data structures, and user input/output, with specific requirements for each task.

Uploaded by

kcharachimwe
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/ 78
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++ (Practical) PAPER NO: 317/13/S02B DURATION : 3 Hours MARCH / APRIL 2015 EXAMINATION REQUIREMENTS INSTRUCTIONS TO CANDIDATE 1. Answer all questions 2. Print the program listing together with the output screens for each question This paper consists of 2 printed pages. 317/13/S02B -PROGRAMMING USING C++ (PRACTICAL) QUESTION 1 VS Demonstrate the understanding of the do.. while construct by coding a c++ application that allows the user to enter a number and display the entered number ‘on the console screen. In addition the program should terminate when the user enters a zero (0). Test your application with the following values: 5, 67 and 0. (10 marks) QUESTION2 \_“ ‘The volume of a sphere is calculated using the following formular: Vesa 3 Code a C++ program to compute the volume of a sphere. In your solution demonstrate your understanding of the use of #define pre-processor directive to declare a constant identifier (). Test your program with the value of x = 5 (15 marks) UESTIONS «© \~ Develop a C++ program that allows the user to key in firstname and surname separately from the keyboard. The program should then send the details to a text file called “example.txt”. In your program include another function that extracts the details from the file and display the details on the console screen. Hint: In your program create the following functions: a) Output-to-file () that allows the user to create a text file and send first b) name and surname to it Input-from-file () that extracts firstname and surname from the text file (25 marks) and display on the console screen QUESTION4 = / Develop a C++ menu driven calculator program using the guideline given below Function addition() to sum up first number and second number Function subtraction() to subtract first number from second number Function multiplication() to multiply first number and second number Function division() to divide first number by second number iv) v) Function modulo() to determine and display modulo of first number and (25 marks) second number QUESTION 5 Code a C++ program to capture 10 employee information from the user and then display the information which was entered by the user. In your program include the following fields (Employee_Id_no, sex and age) NB: The program must use structures (25 marks) [km a 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/13/S02B (Practical) DURATION: 3 HOURS | MARCH /APRIL 2016 EXAMINATION REQUIREMENTS 1, Removable storage media 2. Printing facility and Bond Paper 3. C** Compiler INSTRUCTIONS TO CANDIDATES Answer all questions Save all your work Print all your answers Type your name and candidate number on every sheet At least 3 blank sheets for rough work 2 ROdE OC NIEM are PAPER NO: 317/13/S02B- PROGRAMMING USING C++ (PRACTICAL) QUESTION 1 a) Write a program that uses the switch construct, to prompt the user for a mark obtained by a student in an exam. The program must 7 evaluate the mark and display the corresponding grade (12 marks) Mark J0t030 | 401050] Sito64 | 651074 75 to 100) Grade U D Cc B A b) Write a program that prompts the user for an integer value that represents any number of seconds. Your progralt should then display the number of minutes, hours and days that the given seconds represent. Truncate all values Sample Output aie ; 122.46 7b BE Enter the number of seconds: 100 000 ime ees ‘ gh 1@ 36 - com iw = 100 000 seconds = 1 666 minute(s) ih = 62 x69 36 100 000 seconds = 27 hour(s) 120 100 000 = 1 day(s) (10 marks) ¢) Write a program which accepts two integer numbers and display the largest number using the ternary operator (Z marks) UESTION 2 a) The time of flight (t) of an object in space is given by * t=2*2 g where g = force of gravity, and V = velocity bid a program in C++ to input velocity and gravity and determines e time of flight of an object (8 marks) b) Using for loops write a program to produce the following output Li 222 3 33333 5 4444444 | 555555555 % (10 marks) 213- PROGRAMMING USING C++ (PRACTICAL) PAPER NO: 317/13/S0: a single for loop to produce the following cc} Write program that uses output 1 2 3 4 8 6 7 8 9 10 1 12 13 14 15 16 17 18 19 20 24. 25 «26 «270 «28 29 30 ane eee 37 38 «39 «40 31 32 33 34 35 36 a2 43 4445 46 47 4B SO Lk bg b4 65 66 «67:«68- «6D 7O 61 62 63 64 6 dale QUESTION 3 Write a menu driven program that accepts two integer values and an operator from the keyboard and performs arithmetic operations on the two integers based on the operator selected. Your program should consist of the following functions a) Function showChoice to display the menu b) Function Add that accepts the two integers as parameters and return the sum Function Subtract that accepts the two integers and returns the difference ) d) Function Multiply that accepts the two integers as parameters and returns the product e) Function Divide that accepts the two integers as parameters and returns the quotient (20 mark 7 UESTION 4 Write a program that captures information for ten employees. ‘The details be captured for each employee are Name, job Title, salary The program should then calculate the total wage bill for the ten employee UESTION 5 (15 mar Le a program that creates a text file called “file1.txt” and stores the nai age of one student. The program should read the information from tl file and display it on the screen (10 mai PAPER NO: 317/13/S802B = PROGRAMMING USI MBCA TIONG oo, MENT" MONA es whether a number entered mber is even, the prot UME Code a program that determin keyboard is even or odd. If the nut the messag SNTERED A POSITIV i ODD, the program displays the messe AN ODD NUMBE (10 marks) Using appropriate escape sequences code a program that displays the following:~ EDUCATION PROFILE SUBJECT ‘CODE TITLE. GRADE S01 IT DISTINCTION S02 CH CREDIT SO3 COP, CREDIT S04 BIS PASS. \ SOS ACCOUNTS DISTINCTION | S06 BCOM PASS (io marks) QUESTION 2 fa)! Code a menu driven program which displays the following menu: TODAY'S MENU 1, SADZA REZVIYO $5.00 CHETE 2. SADZA REMHUNGA $4.00 CHETE 3, SADZA RECHIBAGE $1.00 CHETE $2.00 CHETE 4, MUPUNGA Enter choice ering number in the range 1 -4. am asks the till operator to enter culates the change due to for the number of (10 marks) The user chooses an option by ent For each program option the progr amount presented by the customer and call the customer. Assume the program also asks plates required. Given that the US Dollar Exchange rate against other currencies is as follows: 1USD is equivalent to 12 South African Rands 1USD is equivalent to 5 Zimbabwean Dollars 1 USD is equivalent to 10 Chinese Yuan 1 USD is equivalent to 2 British Pounds Code a program that accept a given amount in US Dollars and convert it to the requested currency. 110 marlro) PAPER NO, 317/13/S021, PROGRAMMING USING C++ PRACTICAL A school pupil is having, involving the digit 7, You are he following mathematical table using displa loop construct 7x97 7x2 7x3 =21 7x4 7x5=35 7x6 = 42 7x7 =49 7x8 = 56 7x9 = 63 7x 10 = 70 (10 marks) atedly collects positive integers from the Code a program that repe ser enters a negative number or zero. After (b) user, stopping when the u that the program displays the product of all positive entries. A ‘ample run should appear on the screen like the text below: Enter anumber: 3 Enter a number: 10 Enter a number: 2 Enter a number: -2 The product of all positive number is 60 (10 marks) QUESTION 4 (a) | Given the following array declaration / Int CensusAges[ ] ={5,6,70,95,50,3,4,2,20,12}, Code a program that searches the array and displays the following. (i) | The number of people whose age is 5 and less The number of people whose age is at least 70 (ii) (iii) The number of people whose age is between12 and 70. (10 marks) Code a program that creates an array of 10 integers and sort them (10 marks) in descending order. PAPER NO: 317/13/S802B - (b) PROGRAMMING USING C++ PRACT Code a program to calculate the factorial of a number entered at the keyboard given that the factorial of number nie, nl = n (n-1)x(n-2)x(n-3) x1 e.g Sl 5x4x3x2x1=120. Use a FUNCTION to compute the factorial. Also note that if the number<= 0 then factorial = 1. (5 marks) Code a program that creates an array of structure called STUDENTS. Array size is five (5). The structure is made up of the following fields: Name, surname and mark. The program calculates and displays the smallest mark and the (15 marks) average mark. wen 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/13/S02B (Practical) DURATION: 3 HOURS | MARCH /APRIL 2016 EXAMINATION REQUIREMENTS Removable storage media Printing facility and Bond Paper ct* Compiler INSTRUCTIONS TO CANDIDATES ais Answer all questions Save all your work Print all your answers Type your name and candidate number on every sheet At least 3 blank sheets for rough work Faeye PAPER NO:.917/18/802B- PROGRAMMING USING-CH (PRACTICAL) QUESTION 1 hh construct, to prompt the user he program must (12. marks) a that uses the swil nt in an exam. jhe corresponding grade a) Write a prograr for a mark obtained by a studer evaluate the mark and display t 65 to 74 | 75 to 101 Mark JO to 39 | 40 to 50 |_Sitoo4 a D Cc B | A Grade U prompts the user for an integer value that ber of seconds. Your program should then ‘of minutes, hours and days that the given. 1 values, v) Write a program that represents any num! display the number Seconds represent. Truncate all sample Output Enter the number of seconds: 100 0001" ; peons ah 718 3 6008 Aw 100 000 seconds = 1 666 minute(s) 368 100 000 seconds = 27 hour(s) 100 000 = 1 day(s) (10 marks) ce) Write a program which accepts two integer numbers and display the ary operator (Z marks) largest number using the tern: QUESTION 2 ‘the time of flight (t) of an object in space is given by a) t=2*2 g where g = force of gravity, and V = velocity Write a program in C++ to input velocity and gravity and determines (8 marks) the time of flight of an object b) Using for loops write a program to produce the following output 1 u 222 3 33333 5 44444444 555555555.% (10 mark wegen PROGRAMMING USING C+t (PRACTICAL) PAPER NO: 317/13/S02B- cg) Write program that uses a single for loop to produce the following output 10 2 4 5 6 7 8 9 oh i 16 17 «18 19 20 ll 12 13 14 15 21 22 23 24 25 26 27 28 29 a 31 32 33 34 35, 36 37 38 39 Ea 41 42 43 44 45 46 47 48 49 67 68 69 70 : : : : 7 i 61 62 63 64 65 (8 marks) QUESTION 3 Write a menu driven program that accepts two int operator from the keyboard and performs arithmet integers based on the operator selected. Your program should teger values and an tic operations on the two consist of the following functions Function showChoice to display the menu a) b) Function Add that accepts the two integers as parameters and returns the sum c) Function Subtract that accepts the two integers and returns the difference d) Function Multiply that accepts the two integers as parameters and returns the product e) Function Divide that accepts the two integers as parameters and returns the quotient (20 marks) QUESTION 4 Write a program that captures information for ten employees. The details to be captured for each employee are Name, job Title, salary The program should then calculate the total wage bill for the ten employees (15 marks) QUESTION 5 Write a program that creates a text file called “file1.txt” and stores the name and age of one student. The program should read the information from the file and display it on the screen (10 marks) ZIMBABWE ERTIARY EDUCATIO MINISTRY OF HIGHER AND T MENT SCIENCE AND TECHNOLOGY DEVELOP HIGHER EDUCATION EXAMINATIONS COUNCIL (HEXCO) NATIONAL CERTIFICATE IN INFORMATION TECHNOLOGY SUBJECT: Programming Using C++ PAPER NO: 317/13/S02B (Practical) DURATION: 3 Hours BEE EEEEE EEE EEE EE EEE Pees CEE ECE EE EEE oeeEE LECCE CceeeeCee ci iL Cea Saeco MARCH/APRIL 2017 EXAMINATION REQUIREMENTS pw Computer with a C++ compiler 5 Storage device and printing facility 3. At least 2 sheets of paper for rough work INSTRUCTIONS TO CANDIDATES Answer all questions 2. Print both code and output we (021 - PROGRAMMING USING C++ (PRACTICAL) JR NO: 317, SSTION_1 Write a program that accepts two integers as input and then calculates “a and displays the sum, difference and product of the two integers. (10 marks) Write a program that prompts the user to enter values for hourly rate and hours worked. The program should compute and display gross pay, which is calculated as hours multiplied by rate for the first 40 hours, plus hours multiplied by 1.5 multiplied by the rate for any extra hours after 40. The program should also display net pay, which is gross pay minus tax which is calculated as 28% of gross pay if gross pay is over % of gross pay if gross pay is not over $1000 but is over $1000, 21 $600, and 10% of gross pay if gross pay is not over $600 (15 marks) QUESTION 2 Code a program using functions that displays the following menu: 1. Factorial 2. Prime 3. Odd/Even 4. Exit Enter choice The program allows the user to make a choice from the menu. If the user choose 1, the program asks the user to enter a positive integer, calculates and displays the factorial of the integer. If user chooses 2, the program asks the user to enter an integer, checks whether the integer is prime or not and displays an appropriate message. If the user chooses 3, the program asks the user to enter an integer value, it checks whether the value is odd or even and If user chooses 4, the program displays displays an appropriate message. (20 marks) the message “Exit” and terminates, {.,, 317/13/80213 = PROGRAMMING USING C+ (PRACTICAL) on 3 s has a total of 5 students. A student record consists of Name, Age, wee using an array of structures, code a program that accepts all the ender Gen tudent and allows for capturing of 5 student records. The program getails of 2S! qnould display in tabular form the name and age of all female students in (15 marks) the class QUESTION 4 Create a text file called exam. txt using notepad. The file should have two a) lines of text. Write a program to read and display the contents of the text (10 marks) file. Write a program that creates a2 x 2 matrix and accepts the elements of b) the array. The program should display the sum of elements of the major diagonal. For example matrix: 10 3 5 4 Output will be: 14 (10 marks) QUESTION 5 a) Demonstrate function overloading by writing a program that adds two numbers, one function to add integers and the other to add floats. The functions should be called in the main () function and display the results. (10 marks) b) Write a program that accept 5 numbers of integer type and display the (10 marks) average of the numbers using a do.....while loop. ZIMBABWE HER AND TERTIARY EDUCATION, MINISTRY OF HIG TECHNOLOGY DEVELOPMENT SCIENCE AND HIGHER EDUCATION EXAMINATIONS COUNCIL (HEXCO) NATIONAL CERTIFICATE IN INFORMATION ‘TECHNOLOGY SUBJECT: Programming Using C++ PAPER NO: 317/ 13/S02B (Practical) DURATION: 3 Hours MARCH /APRIL 2018 EXAMINATION REQUIREMENTS 1, Computer with a C++ Compiler. 2, Storage device and printing facility. 3. At least 2 sheets of paper for rough work INSTRUCTIONS TO CANDIDATE 1, Answer ALL questions. 2. Print both code and output. PAPER No: 317/13/S02B - PROGRAMMING USING C++ (PRACTICAL) QUESTION 1 8) morder to qualify for a modelling show, an aspiring model must i 65m tall or above. Write a Weigh less than 55kg and must be 1. c program which accepts the aspiring model’s fall name, weight and height and determines whether she qualifies for the Oe i) D)y Write a program that accepts a three digit number from the user, calculates and displays the sum of the digits in the number aS well as the number in reverse order. For example, if your numbeT is 279, the sum of the digits is 18 and the number in reverse OF ler is 972. Use a while loop. (10 marks) UESTION 2 Write a menu driven program that allows a person to select a d his/her choice. Your program must have the following functions *ShowDivision *Commerce *Engineering *Applied Arts Given that Commerce courses cost $275 per term and take two years to complete National Certificate, Engineering courses cost $300 per term and take 3 years to complete National Certificate while Applied Arts courses cost $250 and take 2 years to complete National Certificate. Your program should calculate and display for the user the total fees required to complete National Certificate in the selected division. Use the Switch statement. (20 marks) QUESTION 3 a) A retail shop sells a variety of products and intends to store their product details in the computer. The following details will be stored for each product: ProductID, description and unit cost. Write a program that accepts and stores the details of the products. Your program should calculate and display the total unit cost of all the products and display the details of the products in the following format ivision of ProductID Description Cost co148 Counter Book 1.00 F210 File 2.40 Total cost = 3.40 In tha ahan 15 marble) Whava ava Ko nendiea! 3/802B = PROG RAMMING USING C++ PRACTICAL} prototyping, write a st n terms acci terms and ( PAPER NO: 3 unction d displays the fir n to calculate the fibon: 5 marks) y Using your knowledge of fi ¢ program that generates ant of Fibonacci. Use & functio: he main function display them in t 0 integer elements. QUESTION 4 nd loads an array of 2 cending order. Display both (20 marks) . dda a program that creates a r program should sort the array in des th ¢ unsorted and the sorted arrays. UESTION 5 Using notepad, wri age eachina id, write you gi fetes uur name, surname, course and i separate line. Save the file as myfile.txt. Write a C++ program that read: s (10 marks) the informati: ion from the file and display it on the screen sfab 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++ (Practical) PAPER NO: 317/18/S02B DURATION: 3 hours OCTOBER/NOVEMBER 2018 EXAMINATION REQUIREMENTS 1. Computer with C++ compiler. 2, Storage and printing facility. 3. Two(2) sheets of paper for rough work. INSTRUCTIONS TO CANDIDATE 1, Answer all questions, 2, Print both code and output. 3. Submit both hard copy and soft copy. See ZIMBABWE ERTIARY EDUCATION, MINISTRY OF HIGHER AND T LOPMENT SCIENCE AND TECHNOLOGY DEVE! HIGHER EDUCATION EXAMINATIONS COUNCIL (HEXCO) NATIONAL CERTIFICATE IN INFORMATION TECHNOLOGY SUBJECT: Programming Using C++ (Practical) PAPER NO: 317/18/S02 DURATION: 3 hours 8 Serra OCTOBER/NOVEMBER 2018 EXAMINATION REQUIREMENTS 1. Computer with C++ compiler. 2. Storage and printing facility. 3. Two(2) sheets of paper for rough work. INSTRUCTIONS TO CANDIDATE 1. Answer all questions. 2. Print both code and output. 3. Submit both hard copy and soft copy. SING C++ (PRACTICAL) PAPER NO: 317/18/S02B — PROGRAMMING NON 1 ves a 10% discaunt for all customer payments between $100 A shop owner *) and $200 and @ 20% discount for all payments above $200. Write a program that asks the till operator to enter the amount paid by the customer and then calculate and display both the discount allowed and the final amount to be paid by customer. (15 marks) b) Write a program to display the following output using a single cout statement Subject Mark Maths 90 Science 70 Shona 60 (5 marks) QUESTION 2 a) For any character entered by the user, write a program to determine whether the character entered is a capital letter, a lower case letter, a digit or a symbol. The following table shows the range of ASCII values for characters, digits and symbols. Characters ASCII A-Z 65-90 a-z 97-122 0-9 48 - 57 Special_symbol 0-47, 58-64, 91-96, 123-127 (10 marks b) Write a C++ program to output all even numbers in the range 1 to 20. Use loops. (10 marks QUESTION 3 a) Write a C++ program that computes and displays the sum of the following series: yer 2x+- 1S 3454749411413 415417419421 (10 marks) b) Code a C++ program to display the following pattern: Use loop. Emr ror TITIIT Lon rI.r SS NO: 317/18/S02B ~ PROGRAMMING USING C++ (PRACTICAL) QUESTION 4 ‘ode a program that captures information for 5 students. The details to be captured for each student are firstname, surname and gender. The program should then output all records for female students. The output should follow the format: FIRSTNAME SURNAME GENDER (15 marks) QUESTION 5 Using Notepad, type a paragraph about yourself and save it as exam. txt, then a) code a program to read and display the contents of the file. (10 marks) b) Using classes write a program to capture two different times in the form of hours, minutes and seconds. The program should add the two times to obtain their sum in the same format of hours, minutes and seconds (HH:MM:SS) as the output. (15 marks) ma 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++ (Practical) PAPER NO: 317/18/S02B DURATION: 3 hours a MARCH/APRIL 2019 EXAMINATION ——=———— REQUIREMENTS 1. Computer with C++ compiler 2. Storage and printing facility 3. At least 2 sheets of plain paper for rough work ) INSTRUCTIONS TO CANDIDATE 1. Answer all questions. Ne 2. Print both code and output, ST ee 5. Submit both soft copy and hard copy. 4st (PRACTICAL) mine and display all factors of 1 200, which are (10 marks) also multiples of 6. Using a ternary operator, write a program to determine if a captured integer is (7 mark even or odd. 4 QUESTION 2 a) Using the switch construct, code a program to display name of the month. When the user enters the month’s numerical value e.g. if user enters 1 then program displays January’, if 12 is entered then ‘December’ is displayed. (15 marks) b) Code a program which, given the distance between two cities in km and the speed at which the traveller will drive in kilometres per hour, calculates and displays the time it would take in hours to reach one city from the other. (8 marks) QUESTION 3 vy Write a program to input an integer between 2 and 12 inclusive and output a multiplication table of numbers from 1 to the number captured e.g. if 6 is captured, the table below should be displayed. a) 1 2 3 4 5 6 2 4 6 8 10 12 3 6 9 12 15 18 4 8 12 16 20 24 5 10 15 20 25 30 6 12 18 24 30 36 (10 marks) b) Using a function, code a program to produce and display the following. Use loops. yD A ; ce Pi B c O , 7 E F OY G H I J K L M N Oo (10 marks) PAPER QUESTION 4 (PRACTICAL) NO: _317/18/S02B = PROGRAMMING USING C ores details of five (5) students (Studid, Name, Mark). Write h an array and output a list of students who have failed, Le marks) i ructu ay of s b) Code a program that creates a text file called ‘exam.txt’. The program should allow user to type text into the file. Program should then read from the file and display the contents. It should also calculate and display the total (15 marks number of words in the file. Using classes, write a C++ program to capture student details (Name, RollNo, Total and Perc). The program should make use of a function getDetails (] to capture student record and function putDetails () to display the student record. Program should output the student’s Name, RollNo, Total and Perc, where Perc is a float given by the formula per = total/500 * 100. (10 marks 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++ (Practical) PAPER NO : 317/18/S02B DURATION: 3 hours REQUIREMENTS 1) Computer with a C++ compiler and ms office. 2) Storage medium for each candidate. 3) Printing facility. INSTRUCTIONS TO CANDIDATE 1) Answer all questions, 2) Print both code and output screens. 3) Submit both hardcopy and softcopy. This paper consists of 3 printed paaes. PAPER NO: 317/18/S802B PROGRAMMING USING C++ (PRACTICAL) QUESTION 1 a) v) Write a program that prom pts the user to enter two sides of a rectangle and calculates and display: 's its area and perimeter. (8 marks) Moyo has just acquired a plot of land that he costing $25.40 per metre and each fence post will cost him $12.40. Moyo has decided to put 2 metres long gate which will cost him $270 to put up. Write a program to help Moyo calculate the total amount of money that he will need to fence his plot. The program asks Moyo for the length and width of his plot in metres as well as the number of fence posts that he will need. The program then calculates and displays the total amount that Moyo will need, eds to fence. Fence is (12 marks) QUESTION 12 a) b) Johnson Transport charges its customers for the transport services based on the following criteria: Distance in km Charge per km Up to 100km $27.60 (Next 200km $19.70 Above 300km $15.00 A surcharge of 796% is added to all customers. Write a program that will be used by Johnson ‘Transport to calculate and display the amounts to be paid by its customers after the user has entered the distance travelled (in km). (13 marks) Write a program that calculates and displays the average of all integer numbers entered by the user. The number of members is not known in advance and the user continues to enter numbers until he/she enters « user otters =| (10 marks) QUESTION 3 a) b) Create a text file using notepad and add text to the file. Write a program that reads the text from the file and displays it on the screen. Your program should also count and display the number of characters in the file, (12 marks) Write a program that produces the following output using for loops. ' (10 marks) 23 n56 14410 , pAPER NO: 317/18/S02B PROGRAMMING USING C++ (PRACTICAL) QUESTION 4 a) Write a C++ program that determines whether a number entered by a user is odd or even using the ternary operator. (5 marks) ») Write a program that stores the following product details for 10 products in stock: — Product number — Product name — Unit price and — Quantity Your program should then display the details of all the products in stock in tabular form as well as the average unit price. (10 marks) QUESTION 5 a) Write a program that accepts two numbers from the user in the main function, pass the numbers to a function called “calculate Product”. The function will find the product of the two numbers using a loop and return the product to the main function where it will be displayed. (10 marks) Write a program that allows the user to enter the principal, rate and time of an investment and calculates and displays the simple interest receivable using a class. (10 marks) y ZIMBABWE E ERTIARY EDUCATION, MINISTRY OF HIGHER AND T: INNOVATION, SCIENCE AND TECHNOLOGY DEVELOPMENT HIGHER EDUCATION EXAMINATIONS COUNCIL (HEXCO) NATIONAL CERTIFICATE + IN INFORMATION TECHNOLOGY SUBJECT: Programming using C+ + PER NO: 317/18/S02B (Practical) DURATION: 3 hours REQUIREMENTS 1. Computer with C++ compiler. 2. Storage medium for each candidate. 3. Printing facility. INSTRUCTIONS TO CANDIDATE 1. Answer all questions. 2. Print both code and output. 3. Submit both hard copy and soft copy. This nans= > 3. ~ PROGRAMMING USING C+ + (PRACTICAL) PAPER NO: 317/18/S021 Write a C+ + program that produces the following output using a single cout SA catement “Beware of bugs in the above code Ihave only proved it not tried il!” (7 marks) A farmer has had a good harvest this season. He plans on setting up a Mahou processing plant at his farm. He intends to buy a tank to use for the storage of his product. Given that the tank costs $30 per m?, write a program that accepts the radius and height of the tank from the user and calculates and displays the cost of the tank, The volume of the tank is calculated by the (12 marks) formula mr?h, QUESTION 2 User to enter their age and sex and the a) b) Write a program that allows the Program displays the area/place following criteria. where the person can work based on the n urban areas only, § to 50 years old can work anywhere. Years old can work in urban arcas only. (15 marks) Females can work i Males form 18 year: ~ Males from 51 years to 65 ~ Any other input will be treated as an error, T to enter integer num bers until he/she Write @ program that allows the u enters ~1, The program the entered by the user, n displays the (otal number of negative numbers (12 marks) : b) 1. (PRACTICAL) 0218 ~ PROGRAMMING USING C nt account numbers and accou stores the nam loyees with oeee % interest to all cmp! Your program adds 5% inte STE Sane Develop a program t balances of 6 cmployces $1 000 or more in their a holders in the following format. unts and displays the de Account Balance Account Number Name ‘Tavonga $406.25 6346889 Create a file using Notepad, then write a program that finds and displays the number of characters in the text file together with the contents of the file. (14 marks) QUESTION 4 a) b) Write a program that calculates and displays the arca of a rectangle and triangle using function overloading. Use a function prototype for the function to calculate the area of the rectangle. (15 marks) Write a program that calculates and displays the average of three integers entered by the user. Your Program should use a class with two methods, one to calculate the average and the other to display the three integers and their average, (10 marks) ZIMBABWE iON, TIARY EDUCATI YY OF HIGHER AND TER’ MN OVATION, > SCIENCE AND ‘TECHNOLOGY DEVELOPMENT HIGHER EDUCATION EXAMINATIONS COUNCIL (HEXCO) NATIONAL CERTIFICATE IN INFORMATION TECHNOLOGY SUBJECT: Programming Using C++ PAPER NO: 317/18/S02B (Practical) MINATION _ ‘DURATION: 3 Hours MARCH/APRIL 2023 REQUIREMENTS Computer with C++ compiler Storage medium for each candidate 3. Printing facility INSTRUCTIONS TO CANDIDATE 1. Answer all questions. 2. Print both code and output. 3. Submit both hard copy and soft copy. This paper consists of 3 printed pages. PAPER NO: 317/18/S02B - PROGRAMMING USING C++ (PRACTICAL) UESTION 1 i for the dimensions of a Write a program which prompts the user h 7 papesiun ‘and calculates the area of the trapezium NB Area of a trapezium = (a+ b)/2*height (10 marks) a program that display the following pattern using for loops 2 3 5 b) Write 1 Behe eet 1 2 38 72 1 (10marks) Ise statement, write a program that accepts a given amount in our Jocal currency and converts it to the selected currency using the exchange rates below: 1Rand= Rtgs 10 USDS$1 = Rtgs 80 1 Pula = Rigs 50 The program should display a menu to allow the user to choose the currency s/he wants. The program should display the amount entered and its equivalence in the + (15 marks) selected currency. UESTION 3 Write a program to store details of seven (7) handball players in a structure called players, The Program captures the following details; name 3 > age and gender of the players. Print the details of the youngest player. (15 marks) MMING USING C++ (PRACTICAL) 17/18/S02B - PROGRA PAPER NO: 3 ¢ UESTION 4 - Write a program which allows the user to enter two matrices. The progr 7 ill find the sum of the matrices and display the sum as the third mati (15 marks) matrix. «Buyers.text”. The program b) a) » Write a program that creates 2 text file called hree (3) names into the file and the should allow the user to type ad from the file displaying the contents. (10 marks) program should re: QUESTION 5 Using a function, write a program that evaluates two numbers entered by the user and displays the largest of the two. (15 marks) Develop a program that allows the user to enter dimensions of a triangle using a class named ‘Triangle’. The program should calculate and display (10 marks) the area of triangle. .-/km / ZIMBABWE IN TARY EDUCATION, OF HIGHER AND TERT! MNS OVATION, SCIENCE AND "TECHNOLOGY DEVELOPMENT TIONS COUNCIL HIGHER EDUCATION EXAMINA’ (HEKCO) NATIONAL CERTIFICATE IN INFORMATION TECHNOLOGY NO: 317/18/S02B SUBJECT: Programming Using C++ (Practical) PAPER DURATION: 3 Hours 1. Computer with C++ compiler. 2. Storage medium for each candidate. 3, Printing facility. INSTRUCTIONS TO CANDIDATE 1. Answer ALL questions, 2. Print both code and output, 2 . Submit both hardcopy and soft copy. CLUS a Paper consists of 2 printed paaes. "ROGRAMMING USING C++ (PRACTICAL) write a program that calculated the volume of a sphere when given the (10 marks) radius. Use the formula V = : nr3, Write a program to find the sum of first n natural positive integers, which are multiples of 5. Positive integers such as 1,2,3 ... n are known as (15 marks) natural numbers. QUESTION 2 Write a program to develop a simple calculator with the following operations; */,-.+ using the switch statement. (15 marks) QUESTION 3 Write a program to enter 5 integer elements in an array. The entered elements will be printed in descending order. (15 marks) QUESTION 4 f) Write a program that creates an array of structure called Employees to capture details of 5 employees. The structure has the following: name, surname, department and salary. The program prints details of employees, calculates and prints Employees’ average salary. Example of output Name Surmame Department Salary Annah Bhebhe Marketing 413 Salary average is (15 marks) (b) Writea Program that uses a function to find the sum and average of 5 numbers entered by the user. (10 marks) UESTION 5 (@) Write a program to input 10 names fi i : rom the keyboards write the names toa file named “Friends. txt” and display the names on the screen. (15 marks) (b) a program to capture book details (title, author, (10 marks) ZIMBABWE EDUCATION, HIGHER AND TERTIARY PX LOPMENT OF MINISTRY OF yee AND TECHNOLOGY INNOVATION, SCIE! HIGHER EDUCATION EXAMINATIONS COUNCIL (HEXCO) NATIONAL CERTIFICATE IN INFORMATION TECHNOLOGY MODULE: Programming Concepts (Practical) PAPER NO: 317/22/M02B DURATION: 3 hours | JUNE 2023 EXAMINATION REQUIREMENTS 1. Computer with C++ compiler 2, Printing facility 3. Storage medium for each candidate INSTRUCTIONS TO CANDIDATE 1. Answer all questions. 2. Print both code and output. 8. Submit both hardcopy and softeopy. This paper consists of 3 Printed page. S. R pana no. 217/2/4028 = PROGRAMMING CONCEETS PRACESAS ‘ CEPTS (PRACTICA! , (028 - PROGRAMMING CON! / PER NO: 317/22. ‘ write a corresponding program from the Question 1 Using the structure of a C++ program, a) 7 given ‘flow chart. ‘Area = length * width (10 marks) Write a program that allows the user to enter a number, it then checks (10 marks) b) whether the entered number is prime or not. QUESTION 2 Write a program that prompts a student to enter marks in an array of size 5. The program calculates the average mark and displays grades as shown below: if average mark is greater than 80, “Grade is A” if average mark > 60 and < = 80, “Grade is B” if average mark > 40 and < = 60, “Grade is C” if average mark < 41, “Grade is D” Use a For loop for capturing marks, (15 marks) marks (MING CONCEPTS PRACTICAL) 317/22/MO02B PROGRAM! qupstions i r details of five (5) employees in a structare called a) Write oe ram an eaptures the orn Petals, Name, Salary and Years wee main adds 10% increment if years of service is 10 years Paint the details of the employees (15 marks) of Service. Your pr : sad above, otherwise add 5% increment. ent in a tabular form. alculates Sher ealcilation of the incre integer values using a loop and c: (10 marks) b) Write a program to accept five (5) WeXSerage. Use a function to calculate the average. QUESTION 4 creates an array of 10 integer elements. The progam will to enter a specific integer then search the element from (15 marks) a) Write a program that then prompt the user the array and display the position of the element. Using notepad, create a text file called “Final” and write your candidate b) number, subject code and subject title each on a separate line. Write a program to create and display the contents of the file on the screen. (10 marks) UESTION 5 Usi ‘ sing a class called Shape, write a program that accepts the length and width of a rectang is re Se eg the area and displays it on the screen. The class must have length and width, a method to capture the length and width, a method od to calculate the area and a method to display the calculated area. (15 marks IN, TERTIARY EDUCATION, TRY OF HIGHER AND MN NNOVATION, SCIENCE AND TECHNOLOGY DEVELOPMENT HIGHER EDUCATION EXAMINATIONS COUNCIL (HEXCO) NATIONAL CERTIFICATE IN INFORMATION TECHNOLOGY MODULE: Database Concepts (Practical) PAPER NO: 317/22/MO03B _ gists, DURATION: 3 Hours [NOVEMBER / DECEMBER 2023 EXAMINATION L_NOVEMBER REQUIREMENTS 1. Computer with SQL compiler 2. Printing facility 3. Storage medium for each candidate INSTRUCTIONS TO CANDIDATE 1. Answer all questions, 2. For each question, print both command and result-set, 3. Submit both hard copy and soft copy. This paper consists of @ Printed pages, pER NO: 317/22/MO3B DATABASE CONCEPTS (PRACTICAL) “QUESTION you are given the following database relations C royee(EmpID), Sumame, FirstName, DateOfBirth, Address EmploymentDate, Gender) Department (DepartmentNo, DepartmentName, project (ProjectCode, ProjectDescription, ProjectLocation) Dependent (EmpID}, DependentNo, DependentName, Gender, Relationship) Location) a) Develop SQL statements to i) Create the database called Mimach. (4 marks) ii) Create the four (4) tables in the database. Attributes DateOfBirth, and EmploymentDate are of data type Date. All other attributes are of text type. Define primary keys for all tables. (30 marks) Add a new column salary between EmploymentDate and Gender in iti) the Employee table. (6 marks) b) Use appropriate SQL statements to: i) Add the following records in the employee table. EmplD | Surname | First [DateOfBirth | Address |EmploymentDate | Salary Gender Name Emp01 | Gono Tom 15/03/1988 | 28 Moyo 1/04/2019 $160.00 | Male Av Harare Emp64 | Bhunu Jane 28/03/1990 | 22 Chineta 13/06 /2018 $576.14 | Female i Masvingo 1p43 | Myero Bruno [18/07/1976 | 7 Jeff Rd (01/06/2008 $916.95 | Male Mutare (marks) ii) Insert the following data into the Department table: DepartmentNo DepartmentName _| Location Boa Mining Kadoma Dos Marketing Harare Dot Logistics Mutare Sales Harare 7/22/MO03B - DATABASE CONCEPTS (PRACTICAL) Add the following data into the Project Table Project Code ProjectDescription | ProjectLocation POG Excavation Kadoma [P07 Construction Mutare Plumbin, Masvingo [poe « (6 marks) iv) Add the following records to the Dependent table. [EmpID___]DependentNo | DependentName | Gender Relationship Emp01 Tinotenda Male [Son Emp06 | D04 Tanatswa Female | Daughter [Empo2_ [Doi John’ ‘Male _| Brother [Emp64__| DO9 Yolanda Female | Daughter [Emp43_ [D11 Chiedza Female | Wife (5 marks) Display details of all Male employees born after 1980. (5 marks) vi) Display details of all employees whose salaries lie between $500 and $1000 in descending order of Surname. (6 marks) vii) Display unique values of Location in the Department table. (4 marks) i) Change the location of project PO7 to Harare. (5 marks) ‘| Write SQL statement to perform the following: i) Add the following database users and their passwords. User Name Password Accounts 04Accounts HR Manager admin@HR! Project Manager projectsMimach Director worksDirector (12 marks) ii) Allow the four (4) users created abo , ve to access, delete and details of the Employee table, (5 fe iii) Remove Department Do3 from the database. (4 marks) iv) i ) Disallow the accountant from deleting data from the Employee table. (4 marks) +/pm ZIMBABWE MINISTRY OF HIGHER AND TERTIARY EDUCATION, INNOVATION, SCIENCE AND TECHNOLOGY DEVELOPMENT HIGHER EDUCATION EXAMINATIONS COUNCIL (HEXCO) NATIONAL CERTIFICATE IN INFORMATION TECHNOLOGY MODULE: Programming Concepts (Practical) PAPER NO: 317/22/M02B DURATION: 3 Hours MAY / JUNE 2024 EXAMINATION REQUIREMENTS 1. Computer with C++ compiler. 2. Storage medium (CD) for each student 3. Printing facility INSTRUCTIONS TO CANDIDATE 1, Answer all questions. 2, Submit both soft copy and hard copy. 3. Print both code and output. This paper consists of 3 printed pages. PAPER NO: 317/22/M02! 1B - PROGRAMMING CONCEPTS (PRACTICAL) UESTION 1 te a program that executes it. a) Given the following pseudocode, wri i) Readx ii) Ready iii) Compute p=x* y iv) Computes =x + vy) Total=s?* p* (@—x)*(pt+y) vi) Print total (10 marks) Write a program that reads the radius of a circle and prints the circle’s b) diameter, circumference and area. Use the constant value 3.14159 for PI. Do these calculations in output statements. (10 marks) JUESTION 2 a) Write a program to create a menu driven program as follows: Main Menu 1) Brick and Block 2) oT 3) Clothing Technology Please select your choice (1 to 3) ») Given that Brick and Block course costs $150 per semester and takes two (2) years to complete, IT course costs $200 » IT c per semester and takes 1 year to complete and Clothing costs $200 per semester and takes 2 years to complete. Calculate and display i 'y total fees required to complete the user. Use the switch statement, : i fe tas mana ae the user in the main QuEsTIONS that accepts three numbers fot tne, The write a program thet orrers toa function called “Nn the product {© fonction al find ‘the product of the numbers Produ tn ton nto ‘where it will be displayed. Tel he mi ; i 1, 2, 3, 4, 5, 6» 7s > following numbers 1, 2, 9 o cant the foe ould deplay the above array Oe ard, Vorpuared elements skipping each thir’ €or a) b) Write a program ts 10 from the keybo: also displays the al the array e.g. 124578 10. QUESTION 4 a) Create a text file called “exam.txt” using Notepad and enter the following lines of text. “This year I will pass programming” “C++ is easy if you practice” oe tal number of characters and also (10 marks) Code a program that counts the tot display the contents of file to console screen b) Write a C++ program using structures that stores surname, age, gender _ and fees of 5 students. Your program should display the list of students in a tabular form whose fees are greater than 10000 and are females. NB: Enter at least 2 students who are females and have fees above 10000. (15 marks) QUESTION 5 Write a C++ program to create a class called “Workers”, The class consists of the following methods getInfo( ) ~ which allows the user to input Salary, number of hours worked per day Calculate( ) which add 1000 to the Salary of the employee if it is less than 10000 Display(_) - method to display the Total Sal i lary for an employee with 1 than 1000 or an employee with salary above 10000... Your program should consists of the following data member. Name, Salary, Hours worked and Total Salary (15 marks) ./pm CATION. y OF HIGHER AND TERTIARY EDU‘ : MN NOVATION, SCIENCE AND TECHNOLOGY DEVELOPMENT (ON EXAMINATIONS COUNCIL 'GHER EDUCATI! - (HEXCO) NATIONAL CERTIFICATE IN INFORMATION TECHNOLOGY, Aah re ae SUBJECT: Programming Using C++ (Practical) PAPER NO: '317/18/S02B DURATION: 3 Hours "2022 EXAMINATION __|j REQUIREMENTS 1. Computer with a C++ compiler. 2, Printing facility. 3, Secondary storage medium for each candidate. INSTRUCTIONS TO CANDIDATE e . Answer all questions. 2. Print both code and output. 3, Submit both hardcopy and soft copy. This paper consists of 2 printed pages. 8/S02B — PROGRAMMING USING C++ (PRACTICAL) PAPER NO: 317/13 UESTION 1 i ber using a Write a program to calculate of factorial of a given num (10 marks) a) Write while loop. hi ee {the following: m that uses a single for loop to print b) Write a progra: 25 5 10 15 ae 50 30 35 oe 70 be 55 60 4 95 phae oo 85 90 (10 marks) QUESTION 2 mber. i 1 a) Write a program to calculate the square root of any given (7 marks) b) Using a function, write a program which inputs three numbers and 7 displays the largest number using ternary operator. (8 marks) QUESTION 3 a) Write a program that accepts two (2) integers from the user, calculates and prints sum of the even numbers between two given numbers. (10 marks) b) Write a program that captures the names of five students and the sheets of bond paper used by each student. The problem analyses the data and displays the name of the student who used the most sheets and the number of sheets used. Use two (2) arrays, one for the names and one for the sheets of paper used. (15 marks) JUESTION 4 Write a program that creates a text file called myexam. The program should write and read from the textfile and then display contents on the (10 marks) a) screen. b) Write a Program that uses a data structure to store the following details of @ vehicle, owner's name, year of registration, vehicle colour and model, The Program sorts the details captured and displays them in ascending order according to year of registration, (15 marks) QUESTION 5 class, write a program that stores details about a product. The details the de ral ‘uct number and description. The Program must accept and display (15 marks) Using a include 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++ PAPER NO: 317/18/S02B (Practical) DURATION: 3 Hours JULY/AUGUST 2021 EXAMINATION REQUIREMENTS PC with C++ compiler and MS Office Storage medium for each candidate 3. Printing facility INSTRUCTIONS TO CANDIDATE Answer all questions Print both source code and Output screens ‘Submit both soft topy and hard copy This paper consists of 3 printed pages. GRAMMING USING C++ (PRACTICAL) PAPER NO: 317/18/S02B - PRO! QUESTION 1 __write-e-program-that-calculates.the.area.and-perimeter.ol.a. circle ___. (10 marks) b) Write a program that uses a for loop and while loop display the following number serics: = r ey 19 18 («161922 2H BSL BAT 40 (10 marks) QUESTION 2 s two one dimensional arrays with the Write a program that initialise: following values: ‘ArrayA — John” “Sam”, “Tom”, “Sue”, “Big” ArrayB ~ “Keith”, “Kitty”, “Koko”, “Don”, “Peace” The program should then exchange the value of the first arrayA into the second arrayB and the values of the second arrayB into the first arrayA. Display the values of the two airays before exchanging and after exchanging. : (15 marks) QUESTION 3 Write a program that displays the following menu: ZUPCO fare (From Harare) Destination 1. Bulawayo 2. Mutare 3. Gweru 4, Exit Entre choice here: When the user selects destination, the program asks for the number of Passengers then calculates and displays the total fare. Given that: Harare to Bulawayo is $50.00 Harare to Mutare is $30.00 Harare to Gweru is $25.00 (15 marks) PAPER NO: 317/18/S02B - PROGRAMMING USING C++ (PRACTICAL) QUESTION 4 array_of structure.called PC_that— captures details for 5 pe: follows: Brand, colour, Price. The program Gisplays details of all PCS whose pric’ ss than $1000.00. (15 marks) _Write.a program.that implements.an ul Develop a program that demonstrates the concept of call-by-reference. The should have a function that takes a salary of an employee and it by 100 (10 marks) a) Develop a program that uses aclass and an object to accept the length and width of a rectangle from the user and then calculates and displays the area of the rectangle. The class should have two methods, one to calculate the area and another to display the area. The input for iengt and width should be done in the, main () function. (13 marks) te @ program that opens a text file, reads it character-by-character to ‘end of the file, “and Displays the number of characters in the file. (12 marks) b) Wri th ~/km sf O ZIMBABWE E ERTIARY EDUCATION, TRY OF HIGHER AND T- EN NNOVATION, SCIENCE AND TECHNOLOGY DEVELOPMENT _R EDUCATION EXAMINATIONS COUNCIL HIGHE! (HEXCO) NATIONAL CERTIFICATE IN INFORMATION TECHNOLOGY UBJECT: Programming Using C++ (Practical) PAPER NO: 317/ 18/S02B DURATION: _3 Hours MARCH/ APRIL 2020 EXAMINATION REQUIREMENTS 1) Answer booklet 2) Computer with C++ compiler 3) Storage medium for each candidate 4) Printing facility INSTRUCTIONS TO CANDIDATE 1) Answer all questions 2) Insert correct candidate number as header on every printed sheet. 3) Print both code and output and insert printed copies in HEXCO serialised booklet and tie together with a string. 4) Submit both hardcopy and softcopy This paper consists of 3 printed pages. PAPER NO: 317/18/S02B -PROGRAMMING USING C++ (PRACTICAL) QUESTION 1 a) — Given the following formula Saut + 1/2 at? Code a program that allows the user to enter the values for u, a and t then calculates and displays the valucs of s. (8 marks) b) Write a program that accepts two integer values and then swap the values without using a thitd variable. Display the values before and after swapping. (9 marks) QUESTION 2 Code a program that uses nested for... loops to display the following pattern: 1 14 Pena ceg 1 4.9 16 1 Aad 16 25 (10 marks) QUESTION 3 Write a program that uses two arrays as follows: arrClass- an array to hold five names ArrMarks-an array to hold five marks. The program should load the two arrays and then print out all names with marks below 50. NB: the name in ArrClass corresponds to a mark in a similar position in ArrMarks. (17 marks) QUESTION 4 Code a program that uses a structure called CPU with fields: model, year and price. The program should allow a user to enter details for five (5) CPUs, three (3) for 1995 and two for any other years then displays all CPU models manufactured in year 1995, (15 marks) The first record must be as below: Model Year Price IBM 1995 190.99 PAPER NO: 317/18/S02B -PROGRAMMING USING C++ (PRACTICAL) QUESTION 5 Write a program that implements main function should accept two integers, two floats and one double value function overloading as follows: The and calls fumetions called overload () to: a) Add the two integers b) Multiply the two floats Calculate the difference of an integer and a float (15 marks) @) Calculate the quotient of an integer and a double. QUESTION 6 Greate a text file called “outtile.txt” using Notepad and enter the following line “Our father who is in heaven” Code a program that counts the number of blank spaces present in the textfile. (9 marks) JUESTION 7 Define a class “student” with the following specifications: Data members: admin integer sname 20 characters english, maths, science float, total float. ctotal () a function to calculate english+mathstscience with float return type. Member functions a function to accept values for admin, sname and student marks Takedata () for subjects English, Maths and Science. This function calls ctotal (). Show data () function to display all the data members on the screen (17 marks) Code a main function that implements the above class. ZIMBABWE, MINISTRY OF HIGHER AND TERTIARY EDUCATION, SCIENCE AND TECHNOLOGY DEVELOPMENT HIGHER EDUCATION EXAMINATIONS COUNCIL (HIEXCO) NATIONAL CERTIFICATE IN INFORMATION TECHNOLOGY SUBJECT: Programming Using C++ (Practical) PAPER NO: 317/18/S02B DURATION: 3 Hours OCTOBER/NOVEMBER XAMINATION REQUIREMENTS 1. Computer with C++ Compiler. 2. Printing facility and storage medium. 3. At least 2 sheets of plain paper for rough work. INSTRUCTIONS TO CANDIDATE 1, Answer ALL questions. 2. Print both code and output, 3. Submit both hardcopy and softcopy. This paper consists of 3 printed pages. PAPER NO: 317/18/S02B - PROGRAMMING USING. C++ (PRAC' TICAL) QUESTION 1 fa) Write a C++ program that allows the user to enter time in seconds and converts it into hours, minutes and seconds. (11 marks) (b) A person invests $1000.00 in & savings account that yields 5% interest. Acguming that all intcrest is left in the account at the end of the year, write a program that calculates and displays the amount of money in the account at Mle end of each year for the first 10 years, Use the formula: ToS Gen” where A is the amount in the account at the end of the n‘® year. pis the original amount invested (the principal) PS ine rate of interest per year and n is the number of years. .B: Display your results in tabular form and format all your amount to 2 decimal places. (14 marks) QUESTION 2 or splays the electricity bill for a ZESA 'd the current meter readings and the -onsumed during the month. For unit and for units Write a program that calculates and di client. The user enters the previous ant alculates the number of units c program ¢ the first 100 units, ZESA changes its clients 60c pe! greater than 100 up to 300, clients pay 75c per unit plus a surcharge that is equal to 10% of the cost. Units greater than 300 are charged at 90c per unit plus a surcharge of 20c of the cost. (15 marks) (by Write a program that displays the following output 1 12 12 3 12 oe 1234 5. (10 marks) QUESTION 3 (a) Write a program that creates and loads an array of 15 integer values. The ‘ber and then calculates and vt program will prompt the user to enter a num) displays the number of times that the number appears in the array. Also display the array. (13 marks) Write a program that creates a text file called “Programming.txt.” and write the following lines of text to the file. LAWS OF SOFTWARE DEVELOPMENT Work expands so as to fill the time available for its completion. Adding more manpower to a late project makes it later. Your program should then read the data from the file and display it on the (12 marks) screen. PAPER NO: 317/18/S02B - PROGRAMMING USING C++ (PRACTICAL) JUESTION 4 Write a program that captures t customer name and invoice amount. Your pro; of the customer with the greatest invoice amount. Use a function to determine the (15 marks) greatest invoice amount. Assume there are 5 customers. QUESTION 5 Write a program that uses a class and an object to accept the radius of circle from the user and then calculates and displays the area of circle. Your class should have the data members and two methods; one to calculate the area and the other to display the area. (10 marks) he following customer details: invoice number, gram should then display the details ../en 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++ (Theory) PAPER NO: 317/13/SO2A DURATION: 3 hours MARCH/APRIL 2018 EXAMINATION REQUIREMENTS Answer booklet INSTRUCTIONS TO CANDIDATE Answer all questions. This paper consists of 5 printed pages. PAPER NO: 317/13/S02A - PROGRAMMING USING C++ (THEORY) QUESTION 1 a) Which of the following are valid or invalid C++ identifiers, give reasons: arks) i) grade-point mete ii) integer (2 marks) i ik _ (2 marks) 3 Sop (2 marks) b) Write C++ statements to achieve the following: i ; facet eave aint line: i) Insert the comment “This is my first program in C+*” on a singe! ine ii) Declare a variable called “Married” of Boolean data type. (2 marks) (2 marks) iii) Define a constant called “Rate” with value 3.57. iv) Declare a global variable called “sum” and initialise it with value zero. (2 marks) v] __ Increment the current value of a variable called “count” with value 10. (2 marks) QUESTION 2 Harry allows his customers a discount of 5% if both: ~ The balance on the account is less than $200. - All items outstanding are less than two months old. If one of these conditions is violated, the discount allowed is 2%. Customers who have been trading for more than 3 years are allowed an additional 2% provided that neither of the above conditions is violated. Ilustrate the above system using: a) Algorithm or pseudo code. (10 marks) b) Flowchart (10 marks) [: 0: 317/13/S02A ~ PROGRAMMING USING C++ (THEORY (QUESTION 3. Evaluate the following expression. Show working. a) a=143/(244)-5 42; (6 marks) b) i) Arrange the following data types in order of increasing size and each data type indicate its size in bytes: (8 marks) double, char, float, int ii) With the aid of a code snippet explain how the sequence construct operates. (4 marks) iii) Define the term data type. (2 marks) QUESTION 4 a) Showa trace table or dry run table for the following program and give the output. (10 marks) #include void verse (int versenum) { if (versenum== 0) cout << “Psalms 23\n\n"; else if (versenum== 1) cout << “The Lord is my shepherd \n\n"; else if (versenum== 2){ cout<< “He makes me lie do cout<< “\n He leads me|n|n; } else if{versenum== 3) { cout<< “He restores my soul\n”; cout<< “He leads me in path of righteousness”; couts< “for His name’s sake\n\n"; 3 else if (versenum: { cout<<”I will fear no evil\n’; 4) } int main ( ) { for (int x = 0;x <= 4;x++) verse (x); PAPER NO: 317/13/S02A ~- PROGRAMMING USING C++ (THEORY) return 0; 3 b) Given the following one dimensional array initialisation: int num [| = (1,2,3,4,5, 6,7,8,9, 10}; Write C+ + statements that uses the above array to achieve the following: i) Calculate and display the sum of values at positions 1 and 5 in the array, (2 marks) ii) Cateutate and display the product of values at positions 3 as sas i. iii) Display only even numbers in the array. (2 marks) iv) Display all factors of 8 in the array. (2 marks) ¥) Display the sum of all odd numbers in the array. (2 marks) QUESTION 5 A text file “students.txt” contains four records with the fields: ID, Name and Grade. Write a program segment that reads the conten records on the screen. ts of the text file and display the Output format is as shown below: 1D Name Grade 1345 Mary 3.6 7764 Kuda 7 3324 Tom 3.2 4277 Edson 6.2 (10 marks) b) Given the following structure declaration: struct person { char name [50]; int age; float salary; b NO: 317/13/S02A ~- PROGRAMMING USING C++ (THEORY| Write statements to carry out the following: i) Define a variable called “GUARD” for the above structure. (2 marks) ji) Using the variable “GUARD”, assign name, age and salary with wate “Justin”, “23” and 200.00 respectively. (6 marks) iii) Define an array called “GUARDS” with size 10. (2 marks) Jj 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++ (Theory) PAPER NO: 317/13/S02A DURATION: 3 Hours OCTOBER/NOVEMBER 2017 EXAMINATION REQUIREMENTS Answer booklet. INSTRUCTIONS TO CANDIDATE Answer ALL questions This paper consists of 4 printed pages. Saar oa PAPER NO: 317/13/S02A - PROGRAMMING USING C++ (THEORY) QUESTION 1 (a) Outline any with variable names in C++, five identifier rules that you must adhere to when coming up (5 marks) : useful when coding in C++. (b) Describe any five programming habits that are (5 marks) (c)__ Differentiate the following terms as used in C+ () do while and while loops. (2 marks) (ii) global variables and local variables. (2 marks) (ii) cin and cout. (2 marks) (iv) syntax error and logical error. (2 marks) (v) short and long. (2 marks) QUESTION 2 (2) Draw a flow chart for a i program whi i even numbers between Oand 21. eee ete SE dha ark LE marks) (b) Write pseudocod le for a program that average and displays it on the screen. five numbers, aa their : marks)

You might also like