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

CUIT114 - March 2022 - June 2022 Supp SUPP

The document is an examination paper for a course on Introduction to Procedural Programming at Chinhoyi University of Technology. It includes instructions for candidates, questions on C programming related to arrays, loops, functions, structures, and algorithms for solving problems like checking for palindromes and computing student grades. The exam consists of two sections, with Section A requiring all questions to be answered and Section B allowing candidates to choose two questions.
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)
13 views4 pages

CUIT114 - March 2022 - June 2022 Supp SUPP

The document is an examination paper for a course on Introduction to Procedural Programming at Chinhoyi University of Technology. It includes instructions for candidates, questions on C programming related to arrays, loops, functions, structures, and algorithms for solving problems like checking for palindromes and computing student grades. The exam consists of two sections, with Section A requiring all questions to be answered and Section B allowing candidates to choose two questions.
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 ws” SCHOOL OF ENGINEERING SCIENCES AND TECHNOLOGY DEPARTMENT OF ICT AND ELECTRONICS, COURSE: INTRODUCTION TO PROCEDURAL PROGRAMMING CODE F curr 114 DATE E FEBRUARY 2022 (SUPPLEMENTARY EXAMINATION) DURATION 3 HOURS, INSTRUCTIONS 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. Page 1 of 4 Section A Answer ALL Questions in this Section, This section is worth 50 marks. Question 1 Provide a code fragment to declare an integer array named exam_scores to store 7 scores and calculate the sum of the scores in the array. Question 2 Write the equivalent code, using a while loop, for the following code fortindex = 0; index< 10; index++) printf("index is %d\n", index*10); Question 3 Write a code fragment to print the following pattern of stars. Question 4 a) State the four important parts of a function? b) Which three parts of a function does a caller need to know? Question 5 i. The registration number of a CUT student. ii, ‘The total daily sales at a supermarket. b) The following variables are invalid. For each, give a reason why and correct it. i. 100 percent ii, case iii, exam score Page 2 of & (5) (5) a) B) (4) (6 Question 6 ‘A palindrome is a word, number, phrase, or other sequence of characters which reads the same backward as forward, such as madam, racecar. a) Write down the logic of a function that accepts a string, checks whether the string is a palindrome or not and returns true if it is a palindrome or false if it is not. [8] b) Give the function header of the proposed function el ¢) Give the function prototype of the proposed function 2] 4) Write a statement of a function call of the proposed function BI Section B Answer ANY TWO Questions from this Section. This section is worth SO 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 (5) 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, of all the students. (5) , Calls each function in appropriate function(s) to make the program run properly. 2 Question 8 Write a program that solves a quadratic equation whose values are entered by a user. Your program should have the following functions at the minimum: ) capture values() that allows a user to enter the coefficients of x and x, and a constant of the equation fa] b) find roots(), that finds the roots of the quadratic equation m ©) display(), which displays the roots of the equation B) 4) validated), which checks whether the given equation has real roots or not [5] ©) mainO, for invoking the other funetions BI Page 3 of & Question 9 A lecturer would like a program that allows them to enter a student's scores for a course, compute the average and determine the letter grade of the average mark. The grade is computed as follows: divide the average score by 10 to get the integer quotient. The tables (Table 7.1 & Table 7.2) below show the corresponding letter grades for integer quotients. Quotient | Letter Quotient | Letter Grade Grade 10 A 7 B 9 A 6 G 8 B 5 c ‘Any other F Table 9.1 Table 9.2 ‘Write a program that achieves the above and includes the following: (a) A variable that stores 12 student scores. (b) A function get_score() that (Accepts 12 scores as user input and stores them appropriately. Finds the average of the 12 scores. iii) Returns the average score. (©) A function find_grade() that accepts the average score as a parameter and uses a switch statement to determine the letter grade corresponding to the average. (@) A fanction mainQ that appropriately invokes get_seore() and find_grade() in the right order. THE END Page 4 0f 4

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