Dit 305: Programming Methodology Question Paper

Dit 305: Programming Methodology 

Course:Diploma In Information Technology

Institution: Kca University question papers

Exam Year:2012



INSTRUCTIONS:
1. Answer Any THREE Questions.
2. All Questions Carry EQUAL Marks.
3. Time Allowed is 1hr 30mins.

Question One
a) Briefly discuss the C language basic data types. [8 marks]

b) Define the following terms: [6 marks]
i. Variable
ii. Array
iii. Function

c) A program error can either be syntax, logic or semantic. Classify the errors below: [4 marks]
i. An indefinite loop
ii. Misspelling keywords
iii. Division by zero error
iv. Using an undeclared variable

d) Using 3.14 as PI value, demonstrate how you can create symbolic constants. [2 marks]

Question Two
a) Give reasons why the following identifier names are invalid: [4 marks]
i. 98mark
ii. First Name
iii. #total
iv. char

b) Write a pseudo code algorithm for a program to read the values of a, b and c and display the value of x where: [6marks]
x = a/b - c.

c) Using examples, explain:
i. The difference between a while loop and a do..while loop. [6 marks]

ii. Why the while loop is likely to be more appropriate compared to a do..while loop. [2 marks]

d) Explain the role of the mainfunction in a program. [2 marks]

Question Three
a) Define a pointer as used in programming and show how it is declared. [2 marks]

b) Consider the following program algorithm and write a C program from it. [8 marks]

Start

* Declare int named x, pointer to an int named px
* Assigned the address of x to px
* Assign the value 50 to x indirectly (using the pointer px rather than x)
* Display the value of x indirectly (using the pointer px rather than x)

End

c) Write a C program that reads Total Marks achieved by a student from a set of exams, then prints 'proceed' if the value is greater than 49, otherwise it prints 'fail'. [6 marks]

d) List four relational operator symbols together with their names. [4 marks]

Question Four
a) Define a function called computesum that takes two float arguments, calculates and returns their sum. [6 marks]
(main () function not required)

b) Distinguish between: [4 marks]
i. Array and Struct
ii. Struct and Union

c) Write statements to:
i. Declare an array for 10 books' prices [2 marks]
ii. Read the 4th and 7th prices of the array declared in part c(i) using scanf() [4 marks]
iii. Print all the prices using a ''for'' loop. [4 marks]

Question Five
a) Define the following giving examples: [6 marks]
i. Preprocessor directive
ii. Symbolic constant
iii. Unary operator

b) What is the value of Y in the following expression? Explain the steps of finding your answer: [4 marks]
Y = 20 + 12/2 * 3 - 7%5

c) Given the following structure:
struct order
{ int orderno;
char item_name[10];
int qty;
};

Required:
i. Initialize an order variable named order1 with values (18,Mabati,20) [2 marks]

ii. Print the values on the screen [2 marks]

d) Distinguish between: [6 marks]
i. Source code and object code
ii. Function definition and function call
iii. User defined function and library function






More Question Papers


Exams With Marking Schemes

Popular Exams


Mid Term Exams

End Term 1 Exams

End Term 3 Exams

Opener Exams

Full Set Exams



Return to Question Papers