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

Computer Programming Exam Paper 2022

Programming

Uploaded by

kibabagodwin01
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)
41 views4 pages

Computer Programming Exam Paper 2022

Programming

Uploaded by

kibabagodwin01
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

MAKERE INSTITUTE OF TECHNOLOGY

Diploma and Certificate Examinations


AUGUST 2022 SERIES
PROGRAMME
CERTIFICATION IN INFORMATION AND COMMUNICATION
TECHNOLOGY
PAPER NAME

FUNDAMENTALS OF COMPUTER PROGRAMMING

YEAR I, SEMESTER I

2 HOURS

FRIDAY, 26 TH AUGUST, 2022


INSTRUCTIONS TO CANDIDATES

1. This paper consists of only six questions.


2. Answer only four questions from the listed questions.
3. All questions carry equal marks
4. Begin each question on a fresh page
5. Do not write on the question page
6. All answers and rough work should be done in the official answer booklet
provided.

© Makerere Institute of Technology Examinations Board Turn Over


Question One (20 marks)
(a) Differentiate between the following:
(i) Assembler and compiler (04 marks)
(ii) Procedural programming language and object-oriented programming
language (04 marks)
(iii) Source code and object code. (04 marks)
(b) Define four rules that are used while developing identifiers in programming.
. (04 marks)
(c) Write a program that reads three integers input via keyboard and outputs the
greatest among them. (04 marks)

Question Two (20 Marks)

(a) Explain four datatypes in C programming language. (04 marks)


(b) Explain the following parts of a C program.
(i) #include (02 marks)
(ii) main( ) (02 marks)
(iii) return 0; (02 marks)

(c) Differentiate between pseudo code and flow chart fiving an advantage of
each. (04 marks)

(d) A number is said to be divisible by 9 if it’s even at the same time divisible
by 9 e.g. 36 is divisible by 9 and 27. Write a program that allows you to enter a
number and check the above conditions. (06 marks)

Question Three (20 marks)

a) Define the following terms as used in C programing language.@(02 marks)

i. Data type
ii. Variable
iii. Pseudo code
© Makerere Institute of Technology Examinations Board Page |2
iv. Algorithm
v. Function

b) Write a simple C-language code to do the following @ (03 marks)

i. Print out your name


ii. A program which adds two numbers and prints out the result
iii. Write a C program to solve the following problem.

Question Four (20 marks)

a) Explain why a developer, who is good at both low-level and high-level


programming languages would normally use high level languages when
programming or writing programs. (04 marks)

b) What is machine code? (02 marks)


c) Give four examples of high-level languages (04 marks)
d) Describe three differences between low-level programming languages and
high-level programming languages (06 marks)
e) What do translators do? (02 marks)
f) Identify two translators that can turn high level languages into machine code?
(02 marks)

Question Five (20 marks)

a) Develop a simple ‘C’ program for addition and multiplication of two integer
numbers. (04 marks)
b) List any four keywords used in ‘C’ with their use (04 marks)
c) State any two differences between while and do-while statement. (02 marks)
d) State difference between array and string (04 marks)
e) Write the syntax of switch case statement. (04 marks)
f) State the use of printf( ) & scanf( ) with suitable example. (02 marks)

© Makerere Institute of Technology Examinations Board Page |3


Question Six (20 marks)

a) Define Algorithm. (01 marks)


b) Give the significance of <math.h> and <stdio.h> header files. (02 marks)
c) Give syntax of if-else ladder. (04 marks)
d) Define Array. (01 marks)
e) Explain one dimension and two dimension arrays. (04 marks)
f) Write syntax and use of pow( ) function of <math.h> header file. (02 marks)
g) Write an algorithm to determine whether a given number is divisible by 5 or
not. (03 marks)
h) Explain do – while loop with example. (03 marks)

END
“Wishing you success in your examinations, remember that - Everything that
lives, Starts in our minds ~ Nicholas Loren”

© Makerere Institute of Technology Examinations Board Page |4

Common questions

Powered by AI

Procedural programming languages focus on procedures or routines to operate on data, using a sequence of steps or procedures such as in C. Object-oriented programming languages, like Java, focus on objects that combine data and behavior. Procedural languages follow a top-down approach whereas object-oriented languages use a bottom-up approach with encapsulation, inheritance, and polymorphism as core concepts.

High-level programming languages are preferred because they are easier to read, write, and maintain. They provide abstraction from the hardware, allowing developers to focus more on algorithm development rather than the intricacies of machine code, leading to faster development cycles and easier debugging. High-level languages are portable across different hardware, which isn't the case with low-level languages.

The primary data types in C are int for integers, float for floating-point numbers, char for single characters, and double for double-precision floating-point numbers. These data types define the type and size of data associated with variables, crucial for memory allocation and computation precision.

The switch-case statement allows multi-way branching in C, improving code clarity when dealing with numerous conditions based on a single variable. Its syntax involves the keyword 'switch' followed by an expression in parentheses, with multiple 'case' labels offering different execution paths and an optional 'default' label for unmatched cases.

printf() is used to output data to the standard output device, typically the screen, using formatted strings, while scanf() reads formatted input from standard input, usually the keyboard. For example, 'printf("Enter a number: "); scanf("%d", &num);' displays a prompt for the user to input a number, then reads and stores it.

The 'while' loop evaluates its condition before executing the loop body, meaning the loop body may not be executed if the condition is false initially. In contrast, the 'do-while' loop executes the loop body once before evaluating the condition, ensuring the loop body is executed at least once regardless of the condition.

An array in C is a collection of elements of the same data type, stored at contiguous memory locations. A one-dimensional array is a linear list whereas a two-dimensional array can be thought of as a grid or table, which is a collection of rows and columns, facilitating matrix operations and complex data management.

An assembler is a tool that translates assembly language, a low-level language, into machine code, whereas a compiler translates a high-level programming language into machine code. Assemblers work with one-to-one mapping with machine instructions, whereas compilers generate several machine instructions for a single high-level language statement.

<math.h> includes mathematical functions like pow(), sqrt(), that assist in performing regular mathematical operations. <stdio.h> provides functions required for input and output operations, such as printf() and scanf(), essential for data handling and user interaction in programs.

Machine code is the set of instructions executed directly by a computer's CPU and is written in binary. Unlike high-level languages that are human-readable, machine code is hardware-specific and consists of binary instructions that the computer directly understands, providing the lowest level of control over the system resources.

You might also like