FACULTY OF ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING
2022/2023 FIRST SEMESTER B.ENG EXAMINATION
COURSE CODE: ECE 2105
COURSE TITLE: BASIC COMPUTER PROGRAMMING
SEMESTER: FIRST SESSION: 2022/2023
DATE: DURATION: 2HRS
INSTRUCTION: Answer Question ONE and ANY other THREE Questions
1(a) Determine which of the following are valid identifiers. If invalid, explain why.
(i) Record1 (ii) 1record (iii) file_3 (iv) return (v) $tax (5 marks)
(b) Mention 5 standard keywords in C programming that you know (5 marks)
(c) Write a C programming to add two numbers together (9 marks)
(d) Describe the general form (syntax) of the following statements
(i) The FOR statement (ii) The WHILE statement (iii) The SWITCH statement
(6 marks)
2(a) Describe the following with examples
(i) Expressions (ii) Statement (6 marks)
(b) Write a complete C program to determine the roots of the quadratic equation
2 −b ± √ b2−4 ac
a x +bx +c=0 using the well-known quadratic formula. x= . Allow for
2a
the possibility that one of the constants has a value of zero, and that the quantity
2
b −4 ac is less than or equal to zero. (9 marks)
3(a) A C program contains the following declarations and initial assignments
int i=8, j=5, k;
float x=0.005, y=-0.01, z;
char a, b, c =’c’, d=’d’; - Ascii code of ‘c’ is 99 and ‘d’ is 100
Determine the value of each of the following assignment expressions. Use the values
originally assigned to the variables for each expression
(i) k=(j==5)? i:j (ii) k=(j>5)?i:j (iii) z=(x>=0)?x:0 (iv) i-=(j>0)? j:0 (8 marks)
(b) What are unary operators? How many operands are associated with a unary operator?
(3 marks)
(c) Mention TWO most commonly used unary operators and describe them with
examples.
(4 marks)
4(a) What are the commonly used input/output functions in C? How are they accessed?
(5 marks)
(b) A C program contains the following statements:
#include <stdio.h>
Char a, b, c;
(i) Write appropriate getchar statements that will allow values for a, b and c to be
entered into the computer. (3 marks)
(ii) Write appropriate putchar statements that will allow the current values of a, b
and c to be written out of the computer (that is, to be displayed). (3 marks)
(iii) Solve (i) using a single scanf function and (ii) using a single printf function
rather than the getchar and putchar statements. Compare your answer with
solution to (i) and (ii). (4 marks)
5(a) Write a C program to find the average score of n quiz done by you this semester
(11 marks)
(b) What is the meaning of the following conversion characters for data output
(i) c (ii) d (iii) e (iv) f (v) s (4 marks)
6(a) Write a C program to input principle, time and rate (P, T, R) from user and find
Simple Interest SI=P*T*R/100. (4
marks)
(b) Which of the following are valid string constants
(i) ‘a’ (ii) ‘\\’ (iii) ‘\0’ (iv) ‘$90 (v) ‘\052’ (3 marks)
(c) Name and describe the four basic data types in C. (8 marks)