BIT 1303A 1304  PROGRAMMING METHODOLOGY KCA Past Paper

UNIVERSITY EXAMINATIONS: 2014/2015
ORDINARY EXAMINATION FOR THE BACHELOR OF SCIENCE
IN INFORMATION TECHNOLOGY
BIT 1303A 1304 PROGRAMMING METHODOLOGY
DATE: APRIL, 2015 TIME: 2 HOURS
INSTRUCTIONS: Answer Question ONE and any other TWO

QUESTION ONE
a) Explain how the following three types of operators are used in a C program giving
examples
i) Relational operators. (2 marks)
ii) Arithmetic operators. (2 marks)
iii) Logical operators. (2 marks)
b) Using an example differentiate between the division operator and the modulus
operator as used in structured programming. (4 marks)
c) Differentiate between source code and object code. (2 marks)
d) Explain the five basic data types used in C. (5 marks)
e) Using a code skeleton differentiate between a function prototype and a function
definition. (4 marks)
f)
i) Define the term structure as used in a c program. (2 marks)
ii) Write the syntax of declaring a structure in C program. (3 marks)
g) Explain how a function works in a C program (4 marks)
QUESTION TWO
a) Explain the output of the following code snippets
a) main() (2 marks)
{
int i=5;
2
printf(“%d%d%d%d%d%d”,i++,i–,++i,–i,i);
}
c) #define square(x) x*x (2 marks)
main()
{
int i;
i = 64/square(4);
printf(“%d”,i);
}
d) Write a program using a for loop that calculate the Sum of odd numbers between 1
and 10. The minimum and maximum values should be provided using the keyboard
(6 marks)
e) A string is called palindrome if it symmetric. In other word a string is called
palindrome if string remains same if its characters are reversed. For example: asdsa.
If we will reverse it will remain same i.e. asdsa. Write a c program to check if a given
string is palindrome number or not. (7 marks)
f) Write the output of the following code (3 marks)
#include <stdio.h>
#include <conio.h>
struct student {
int id;
char *name;
float percentage;
} student1, student2, student3;
int main() {
struct student st;
student1.id=1;
student2.name = “Angelina”;
student3.percentage = 90.5;
printf(” Id is: %d \n”, student1.id);
printf(” Name is: %s \n”, student2.name);
printf(” Percentage is: %f \n”, student3.percentage);
getch();
return 0;
}
QUESTION THREE
a)
i) Define the term pointer (2 marks)
ii) Write the syntax of declaring a pointer in a C program. (2 marks)
a) Write a program that uses a function to find factorial of a given number. (6 marks)
a) Write a program to generate the Fibonacci series. (6 marks)
a) Explain the syntax of the if …else if statement (4 marks0
QUESTION FOUR
i). Write a program to find the largest element in an array. (5 marks)
i). Write a simple program that uses a for statement to print the numbers 1 through 20
(4 marks)
i). Write a C program to reverse a string using pointers. (6 marks)
i). Using integer and modulus operator write a c program to find out sum of digit of
given number. (5 marks)
QUESTION FIVE
a) Explain any four components of a C program (8 marks)
a) State the rules applied in naming variable (4 marks)
a) Write a program for swapping two integers (4 marks)
a) Explain the stages of developing a C program (4 marks)

(Visited 87 times, 1 visits today)
Share this:

Written by