0% found this document useful (0 votes)
32 views2 pages

19. SMA 2175 COMPUTER PROGRAMMING 1 EXAM (PAPER II)(1)

This document is an examination paper for the Bachelor of Science in Electrical Engineering at the Technical University of Mombasa, focusing on Computer Programming I. It includes instructions for candidates, five questions covering various topics in C programming, and requires students to attempt question one and any two others. The questions address errors in C, data types, program structure, operators, control structures, and the use of functions and arrays.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views2 pages

19. SMA 2175 COMPUTER PROGRAMMING 1 EXAM (PAPER II)(1)

This document is an examination paper for the Bachelor of Science in Electrical Engineering at the Technical University of Mombasa, focusing on Computer Programming I. It includes instructions for candidates, five questions covering various topics in C programming, and requires students to attempt question one and any two others. The questions address errors in C, data types, program structure, operators, control structures, and the use of functions and arrays.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

TECHNICAL UNIVERSITY OF MOMBASA

INSTITUTE OF COMPUTING AND INFORMATICS


UNIVERSITY EXAMINATION FOR:
BACHELOR OF SCIENCE IN ELECTRICAL ENGINEERING
SMA 2175: COMPUTER PROGRAMMING I
END OF SEMESTER EXAMINATION (PAPER2)
SERIES: SEPT. 2017
TIME: 2HOURS
DATE:SEPT 2017
Instructions to Candidates
You should have the following for this examination
-Answer Booklet, examination pass and student ID
This paper consists of five questions. Attemptquestion ONE (Compulsory) and any other TWO questions.
Do not write on the question paper.
.

Question one (30 marks)


(a) Briefly discuss any two types of errors in C {4 Marks}
(b) Describe the four basic data types in C programming language {4 Marks}
(c) Briefly describe basic structure of a C Program {4 Marks}
(d) List down four relational operators {4 marks}
(e) Explain the following terms as used in programming
- Top down programming method
- Bottom up programming method {6 marks}
(f) Distinguish between a low level language and a high level language {8 marks}

Question two (20 marks)


(a) Identify syntax errors in the following program. After corrections, what output would you expect when you
execute it.
#define PI 3.142
Main
{
Int R, C
Float perimeter

Page 1 of 2
Float area;
C = PI
R = 10;
Perimeter = 2.0*C*R;
Area = C*R*R;
Printf(“%f” “%d”, &perimeter, &area)
} {10 marks}
(b) Describe the format of a C program {10 marks}

Question three (20 marks)


(a) Distinguish between putchar() and getchar() functions {4 marks}
(b) Write a C program that converts a character from a lowercase to uppercase {6 marks}
(c) Explain the if else control structure and write a C program to illustrate the it {10 marks}

Question four (20 marks)


(a) Write a C program to illustrate the use each of the following operators
- Arithmetic operators
- Logical operators
- Relational operators {10 marks}
(b) What will be the output of the following segment when executed {5 marks}
int a = 20, b = 10;
if (a>b)
{
If (b>5)
}
printf(“%d”, b);
else
printf(“%d”, a);
}

(c) Using a program example explain the difference between While and Do-While loop statements {5 marks}
Question five (20 marks)
(a) State three advantages of using functions in a program {3 marks}

(b) Using functions write a program to perform multiplication and division of two variables. {6 marks}

(c) Explain how to initialize a one dimensional array and a two dimensional array {4 marks}

(d) Write a pseudo code and draw a flowchart for a program to find even numbers between 1 to 100 {7 marks}

Page 2 of 2

You might also like