0% found this document useful (0 votes)
37 views5 pages

CSC 201

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)
37 views5 pages

CSC 201

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/ 5
(University of Choice) MASINDE MULIRO UNIVERSITY OF SCIENCE AND TECHNOLOGY (MMUST) MAIN CAMPUS UNIVERSITY EXAMINATIONS SUPPLEMENTARY/SPECIAL EXAMS FOR THE DEGREE IN CIVIL AND STRUCTURAL ENGINEERING/ ELECTRICAL AND COMMUNICATION ENGINEERING/ MECHANICAL AND INDUSTRIAL ENGINEERING COURSE CODE: CSC 201 COURSE TITLE: COMPUTER PROGRAMMING I DATE: 29/07/2022 TIME: 8:00a.m-10:00a.m INSTRUCTIONS TO CANDIDATES Answer Question ONE (1) and any other TWO TIME: 2 Hours MMUST observes ZERO tolerance to examination cheating This Paper Consists of 5 Printed Pages. Please Turn Over. QUESTION ONE [30marks] a) Define the following terms: [4marks] i, Variable ii, assembler iii, loop iv. object code b) Outline rules followed when declaring variables in programing. [3Marks] ©) Explain any two limitations of low level languages. [2Marks} 4) What effects do comments have on a program? [2Marks} €) Mary, a student in MMUST wrote the following code during a programming session Hinclude int main (); char ch="A’; char str[20]="fresh2refresh.com”; float flt=10.234; int no=150; double dbl=20.123456; printf(“character is %d \n",ch); printf(“string is %s \n" str); printf(“float value is %f \n”,flt); printi(“integer value is %ed \n",no); printi(“double value is %lf \n”,dbl); printf(“octal value is %o \n”.no); printf(“hexadecimal value is %x \n",n0); return 0; } Required: identify three errors in the above program, [3 marks] £) Explain each of the following terms as used in programming, [2Marks] i. scanf ii, return 0; 2) Write a C program that uses a function to compute circumference of a circle. [4marks] hh) develop a flowchart that accepts marks scored by a student in three units; calculate the total marks and average marks. Depending on average marks the grades are assigned as follows: A=70- 100 B+60 - 69 C=50-59 D=40-49 Ee 1-39 [10Marks] QUESTION TWO [20marks] a) Using examples, explain FIVE major classifications of programming languages. [10 Marks} b) Using appropriate examples, describe any TWO unary operators used in C programming, [4Marks} ©) Describe any three preprocessor directives [3marks) 4) Write aC statement to evaluate the following equation, [3marks] Side=Va? +b? -2abCOS(x) QUESTION THREE [20marks] a) Write a program to display the following output using while loop. [Marks] 20 15 10 5 0 ) Write aC program that can be used to give an award depending on the average mark of a student using the criteria below [8 marks] ‘Average mark | Award >=80 Distinction 3-65 Credit >=50 Pass <0 Fail b) Briefly describe any two classifications of control structures. [4Marks] ©) Distinguish between the while and do while control structures, [2 marks} QUESTION FOUR [20marks] a) Write a C program to calculate the roots of a quadratic equation Use the quadratic formula b) Study the program below and answer the questions that follow: 1, Hinclude 2. Int main() 3. { 4. Inta,bye; 5. Printf(“enter value of a:"); 6. Scanf(“%d”,&a); 7. Printf(“enter value of b:”); 8. Scanf(“%d” 8b); 9. Printf(“enter value of c:”); 10, Seanf(“%d",&c) 11, Return 0; 12} Explain the function of line 2,4,5,6 and 11 c) Give three differences between compilers and interpreters. QUESTION FIVE [20marks] a) Define the term system development? b) What is a pointer? [12 marks] [5 marks] [3 marks] [2Marks} [2Marks] ©) Write a c program that uses a recursion to compute the factorial of a number which is entered by the user, [6 marks] d) Program control structures dictate the flow and execution of the program. Explain the following types of control structures. i. sequence ii, Selection iii, eration e) Using an illustration differentiate between local and global variables [Marks] [4 marks}

You might also like