0% found this document useful (0 votes)
5 views4 pages

CUIT114 - March 2022 - February 2023 NORMAL

The document outlines an examination paper for an Introduction to Procedural Programming course at Chinhoyi University of Technology, focusing on the C programming language. It includes instructions for candidates, a series of questions in two sections, covering topics such as functions, structures, variable declarations, and programming tasks related to arrays and Fibonacci numbers. Candidates are required to answer all questions in Section A and any two from Section B, with a total of 100 marks available.
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)
5 views4 pages

CUIT114 - March 2022 - February 2023 NORMAL

The document outlines an examination paper for an Introduction to Procedural Programming course at Chinhoyi University of Technology, focusing on the C programming language. It includes instructions for candidates, a series of questions in two sections, covering topics such as functions, structures, variable declarations, and programming tasks related to arrays and Fibonacci numbers. Candidates are required to answer all questions in Section A and any two from Section B, with a total of 100 marks available.
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/ 4
CHINHOYI UNIVERSITY OF TECHNOLOGY rT SCHOOL OF ENGINEERING SCIENCES AND TECHNOLOGY DEPARTMENT OF ICT AND ELECTRONICS INTRODUCTION TO PROCEDURAL PROGRAMMING curr 114 August 2022 3 HOURS INSRUCTIONS TO CANDIDATES Answer ALL Questions in Section A. Answer ANY TWO (2) questions in Section B. All program code should be written in the C programming language, Section A fnswer ALL Questions in this Section. hhis section is worth 50 marks, to 1 vide a code fragment for a function that calculates the mean of scores in an integer array. 5] Aine 2 rite the equivalent code, using a for loop, for the following code [3] int index = 0; while(index < 10) a printf("index is %d\n", index*10); } Question 3 a) Write a code fragment to declare a structure to hold a record for a student. The structure should have a variable to hold the name, the registration number, the gpa, and test results for 5 modules. (6) ) Write a code fragment to declare a variable named student! of the structure defined in a) (2) Qhestion 4 a) State the four important parts of a function? [4] ») Which three parts of a function does a caller need to know? Bl estion 5 a) Declare valid variables for each of the following: i. The registration number of a CUT student, ii, The total daily sales at a supermarket. (4) b) The following variables are invalid. For each, give a reason why and correct it i 100percent ii, case iii, exam score [6] Question 6 rite a program that adds an unknown list of numbers using a looping structure of your noice. The loop terminates when the number just entered is the same as the previous one. 5] Section B pare ANY TWO Questions from this Section. his section is worth 50 marks. Question 7 Write a program that does the following a. Defines a structure called students with the following members: first name, surname, registration number, programme, year of birth. [6] b. Declares an array of type struct students which can store records of five (8) students 2) ®- Uses a function called eapture details () to accept student details for all the students. Use any loop of choice to accept the details. [8] 4 Implements a function show details () which uses a loop to display the details ofall the students, (5] © Calls each function in appropriate function(s) to make the program run Properly. [4] Qtestion 8 Tit Fibonacci numbers are a sequence of integers starting 1, 1, generated such that every Fie tent number is the sum of the previous two. For example, the third number in the Fitfonacci sequence is 2 (because 1+1=2), and the fourth number is 3 (because 2+1=3), (@)}Create a program capable of holding Fibonacci numbers in an array called F. Include a variable called currentNumbersHeld that will record how many of the numbers thefenary being held. Include a constant called maxNumbers, set to 100, that stipulates the}maximum number of Fibonacci numbers that can be held, 5] (©) Create a function called generateSequence that will populate the array with the Fibpnacci numbers accepting one integer argument, N, that specifies how many nurabers to Senprate, Check that N is < maxNumbers. If N exceeds maxNumbers, generate the mayimum number of Fibonacci numbers. 16) Implement a function called displaySequence that will display the Fibonacci sequence cufrently stored in the array in the format: }=1 FIR)=1 (©)[Implement a function called findNumber that will accept user input of a number between i i: 100 and returns the corresponding Fibonnaci number. Foi M 0) ] = 2 so on, (51 example, the function should return 2 when the user input of 3 ‘© sure you validate the user input to make sure that it is within range [5] Implement a main function to invoke the functions, (4) Qupstion 9 Al cor co! (Tal turer would like a program that allows them to enter a studemt’s scores for a course, pute the average and determine the letter grade of the average mark. The grade ic tuted as follows: divide the average score by 10 to get the integer quotient. The tables 1e 7.1 & Table 7.2) below show the corresponding letter grades for integer quotients, Qudtient | Letter Quotient — | Letter Grade Grade 10 A 7 9 A 6 8 B 5 lolalw Any other Table 9.1 Table 9.2 ‘Wrife a program that achieves the above and includes the following: ) A variable that stores 12 student scores, (4 ) A function get_score() that () Accepts 12 scores as user input and stores them appropriately, (ii) Finds the average of the 12 scores. (ii) Returns the average score 19] ({) A function find_grade() that accepts the average score as a parameter and determine the letter grade corresponding to the average. (6 () A function main that appropriately invokes get_score() and find |_grade() in the right order. (6) THE END

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy