0% found this document useful (0 votes)
7 views6 pages

CUIT114 - January 2022 - December 2022 NORMAL

The document outlines an examination for the course 'Introduction to Procedural Programming' at Chinhoyi University of Technology, detailing instructions for candidates and various programming questions. It includes tasks related to C programming, such as output prediction, array manipulation, function components, variable declaration, and program structure. Additionally, it presents practical programming problems involving student scores, employability index calculations, and Fibonacci number generation.
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)
7 views6 pages

CUIT114 - January 2022 - December 2022 NORMAL

The document outlines an examination for the course 'Introduction to Procedural Programming' at Chinhoyi University of Technology, detailing instructions for candidates and various programming questions. It includes tasks related to C programming, such as output prediction, array manipulation, function components, variable declaration, and program structure. Additionally, it presents practical programming problems involving student scores, employability index calculations, and Fibonacci number generation.
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/ 6
CHINHOYI UNIVERSITY OF TECHNOLOGY, SCHOOL OF ENGINEERING SCIENCES AND TECHNOLOGY DEPARTMENT OF ICT AND ELECTRONICS COURSE INTRODUCTION TO PROCEDURAL PROGRAMMING CODE curr 114 DATE fe JANUARY 2022 DURATION : 3 HOURS INSTRUCTIONS TO CANDIDATES 1, Answer ALL Questions in Section A. 2. Answer ANY TWO (2) questions in Section B. 3. All program code should be written in the C programming language. Page 1 0f 6 Section A Answer ALL Questions in this Section. This section is worth 50 marks. Question 1 State the output of the following code fragments. i forli=0;1<10;i=i+2) printf("%d \n", i); ii i= 100; while(i >= 0) { printf("%d \n", — 10; 3 iii. for(i = 1; i<= 10; i++) printf{"%d\n", i); iv. for(i = 2; i< 100; i=i* 2) printf(%d\n", i); (8) Question 2 Given an array declaration int scores{S]; provide a code fragment to calculate the average of the scores stored in the array. 4] Question 3 a) The following code fragment is supposed to calculate the sum of the numbers from 0 to 5, inclusive. Correct the code fragment to produce the correct result of 15, assuming, all variables used have been declared. 2 forli-O;i<5;i++) sum=sum+i; b) Modify the code in a) to give the sum of only odd numbers 2) Page 2 of 6 ©) Give the output of the following code: <3;i-i+1) printf("a\n print{(”b\n"); printf("c\n"); Question 4 a) i. State the four important parts ofa function? ii, Which three parts of a function does a caller need to know? b) The following variables are invalid. For each, give a reason why and correct it i. 6days ii, case iii, total days Question 5 Declare valid variables for each of the following: i, The initial of your last name. ii, The height of a tree. b) The following variables are invalid. For each, give a reason why and correct it. i, 10percent ii, return iii, actual mark Page 3 of 6 (4) BI [6] 4] (6) Question 6 Give the correct version of the following program so that it has no syntax errors and outputs Parameter a is 15 Parameter b is 28 Rate is 15 percent Hincl. ‘main int() { inta int b = 82; inte = 28/15-; int r= 28*15; /this is the rate printf("Parameter c is %d\n", a); printf("Parameter b is Yogin", &b); printf("Rate is %f percent”, rate); 55 2: return return; Section B Answer ANY TWO Questions from this Section. This section is worth 50 marks. Question 7 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 c 8 B 5 c ‘Any other F Table 7.1 Table 7.2 Write a program that achieves the above and includes the following: (@) A variable that stores 12 student scores. (b) A function get_seore() that Page 40f 6 (i) Accepts 12 scores as user input and stores them appropriately. (ii) 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. (d) A function mainQ that appropriately invokes get_score() and find_grade() in the right order. 5] Question 8 ‘An organisation selects one job applicant for an interview by choosing the applicant with the highest employability index. The employability index is calculated using the age and current salary of the applicant as follows: index = 0.3(age) + 0.1(current_salary) Given that each job applicant has the following details: name, age, current_salary( in dollars) and an employability index (initially zero(0) ), write a program for ranking applicants that includes the following: (a) The definition of a structure for storing applicant details and also an array to store a maximum of 3 applicant records. (b) A function for getting input for 3 applicant details and storing these details, appropriately. (o) A function for calculating the employability index of each applicant. The function should overwrite the old employability index information with the newly calculated one. (@) Code that prints out all records of the job applicants. (25) Question 9 ‘The Fibonacei numbers are a sequence of integers starting 1, 1, generated such that every subsequent number is the sum of the previous two. For example, the third number in the Fibonacei 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 are currently being held. Include a constant called maxNumbers, set to 100, that stipulates the maximum number of Fibonacci numbers that can be held, (b) Add a function called generateSequence that will populate the array with the Fibonacei numbers accepting one integer argument, N, that specifies how many numbers to generate. Check that N is < maxNumbers. If N exceeds maxNumbers, generate the maximum number of Fibonacci numbers. Page 5 of 6 (@) Implement a function called displaySequence that will display the Fibonacci sequence currently stored in the array in the format: FU=1 FRj=1 FR] =2 and so on, [25] THE END Page 6 of 6

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