Get premium membership and access revision papers, questions with answers as well as video lessons.
Got a question or eager to learn? Discover limitless learning on WhatsApp now - Start Now!

Coe 162 Question Paper

Coe 162 

Course:Bachelor Of Electrical And Computer Engineering

Institution: Moi University question papers

Exam Year:2010



MOI UNIVERSITY
UNIVERSITY EXAMINATIONS 2010/2011 ACADEMIC YEAR
FIRST YEAR SECOND SEMESTER EXAMINATION FOR THE DEGREE OF BACHELOR OF TECHNOLOGY IN COMPUTER AND COMMUNICATION ENGINEERING
COURSE CODE: COE 162
COURSE TITLE: INTRODUCTION TO COMPUTER PROGRAMMING

INSTRUCTIONS:
1. Answer any four questions
2. Question One is compulsory

Question one(Compulsory)
a) Distinguish between the following programming concepts
I. Objects and operations
II. Compilers and interpreters
III. Procedural and non-procedural languages [3 marks]
b) How do the following characteristic improve the quality of a program
I. Modularity
II. Localization
III. Delayed decisions [3 marks]
c) Draw a flowchart to depict the following examination processing scenario
I. The input consists of students marks in a given course
II. Complain if the mark is below 0 or above 100
III. Determine the grade from the supplied mark(>=70=A;<40=C;otherwise B)
IV. Print grade [4 marks]
d) Explain the output when you execute the following code :
#include<stdio.h>
Void main(){
Int a=5;
{
Int b=10;
=
++b;
++a;
{int a=20;
++a;
a=++b;
}
++a;
++b;
Printf(“%d %d”,a,b);
}
Printf(“%d”,a); [3 marks]
e) Accounting software has to deal with money in amounts exceeding a trillion dollars and yet keep the arithmetic accurate to the penny. What kind of number that C supports would be adequate? [1 mark]
f) Write a simple C program that requests three floating point numbers and prints the sum and product of their square roots to three decimal places [4 marks]

Question Two

a) List four important features of C language [2 marks]
b) What is wrong with the variable declaration and assignment in the following programs?
I. #include<stdio.h>
Int main(){
Int goto=5;
Printf (“%d”,goto);
Return 0;
} [1 mark]
ii.
#include<stdiio.h>
Int main(){
Int BIG=32;
Int y;
Y=_BIG_&&8;
Printf(“%d”,y);
Return 0;
} [2 marks]
c)By means of as simple illustration, show the difference between local variable and global variable as used in C programming [4marks]
d)
I. If n is an integer variable ,what is the value of the expression n%8 when the value of n is 24? [1 mark]
II. What is the value of the expression 2*6-5+8%5 [1 mark]
III. What will be printed when the following segment is executed as part of a program?
Int i,total;
For(i=1 ;i=15;i=i=i+1)
{ if(i%3==0)
{
Printf(“%d”,i);
}
}
Printf(“\n\n”); [2 marks]

Question three

a) What is the difference between the expressions x++ and ++x? [2 marks]
b) Modify the program to achieve the same effect with conditional expression instead of if…..else statement.
#include<stdio.h>
Main()
{
Int n;
Printf(“enter an integer:”);
Scanf(“%i”,&n);
Printf(“\n you entered %i”,n);
If(n>=0)
Printf(“,which isn`t negative.\n”);
Else
Printf(“,which is negative.\n”);
} [4marks]
c) A program contains the following segments
#include<stdio.h>
Float a,b,c;
Write printf function for each of the following groups of variables or expressions using f-type conversion for each floating point quantity
I. a ,b and c with minimum field width of five characters per quantity with nomore than three decimal places
II. Sqrt(a+b), abs(a-c),with a minimum field width of eight characters for the first quantity and six characters for the second quantity. Display a maximum of foru decimal places for each quantity
III. (a+b)+(a-c),with a minimum width of seven characters for the first quantity and six characters for the second.
[7 marks]

Question Four

a) Write a for loop that will compute the sum of every third integer beginning with i=5, for all values of I less than 40. [4 marks]
b) i) Clearly explain the difference between the while loop and the do while loop [2 marks]
ii)Determine:
1) The kind of argument passed to funct [1 mark]
2) The kind of information returned by funct [1 mark]
3) The value displayed by printf statement within funct [2 marks]
c) Define the following array concepts: subscripts, dimensionality of an array and passing an array to a function by reference [3 marks]
d) Suppose y is an array of integers and we have just executed this code:
For(i=0;i<5;i++)
Y[i]=i*i
Suppose that y[0] is stored at address 3500.What is the value of each of the following expressions?
? &y[0]
? y[1]
? &y[1]
? *(&y[2]+1) [4 marks]

Question Six

a)Below is a sketchy outline of a C program

#include<stdio,h>
Main()
{
File *pt1, *pt2;
Int x;
Float y;
Char z;
Fpt=fopen(“sample,old”,”r”);
Fpt=fopen(“sample.new”,”w”);
……………………………………
Fclose (pt1);
Fclose (pt2);
}
Write C statements to do the following:
i. Read the values of x, y and z from the file sample.old [1 mark]
ii. Display each value on the screen and enter an updated value [2 marks]
iii. Write the new values to the data file sample.new [1 mark]
b)Correct the following code ,if necessary , to remove run time or compile time errors .Change the code as little as possible. If no change is needed ,just say so.
Void main(void)
{char x[3];
Strcpy(x,”dog”);
[ 2 marks]
c)Explain the difference between predefined functions and user defined functions [2 marks]
d)Suppose we have a user defined function, long square (long), which returns the square of a number, show how you would go about






More Question Papers


Popular Exams



Return to Question Papers