Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
9 views

Structured Programming

The document outlines an assignment for a structured programming course, including various questions related to C programming concepts such as file handling, structures, and programming errors. It instructs students to attempt all questions and submit their work by a specified date, with references included. Additionally, it covers topics like algorithm definitions, programming errors, and examples of C programs for various tasks.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Structured Programming

The document outlines an assignment for a structured programming course, including various questions related to C programming concepts such as file handling, structures, and programming errors. It instructs students to attempt all questions and submit their work by a specified date, with references included. Additionally, it covers topics like algorithm definitions, programming errors, and examples of C programs for various tasks.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

TAKE AWA'i ASSIGNMENT

Instructlons:

Attempt all the questions


th
Submit 'your work on or before by 11 August, 2018

Include the references at the end of the attempted questions

GENERAL

1. Explain the difference between call by value and call by reference

FILE HANDLING IN C

2. What Is significance of EOF


3. What is a file
4. List the common functions used for reading info frorn and writing info to text files

STRUCTURES AND UNION

5. What is the difference among structure, array and union


6. Write a program in C using structure to calculate total marks and average marks obtained by 8
students in 4 different subjects

,dt.
"1j.. lflr 1 .(.J>'l ~l, ~ l >
1Nl v i:l{ 1 ,,·lt\ 11\! I.)
),-,½ MG.',~,

BIT STRUCTURED PROGRAMMING CAT 1


,\ fOC,~ !, I

1l'l'.~,t ('I £_ Aht-,1q 1pt ALL the Q,u.e:stions


,,,l{ ( f\lll'l" i..'( ' \ fl ) }
20-6--2018
'f· ' I' \\ J-\O i>A l ",b)\
..rro tyf- \... IJ~-1 ~1. Define [2 marks)
~• rJ,t a. Algorithm- rNif~ N\o.)-\C r, I
b. identifier - ~(lri_ obl~ ) f\ ifl"I"'-
2. Describe 4 basic data types in C, include the type of dat2 , the number of bytes and conversion
characterofthe typf [8 rna ' k$)
3. Write a simple C program to receive two float values from the user afld display the sum on the
screen [4 ma rks)
4. Explain _2 logical operators and 2 increment/ decrement operators (4 marks]
LOj, (~\ Cf'<"''>v1.1 - ~ - "lo 01t ,
1

d 1/\ p( ,d ' , ..\/J(t)il'rU\ ~' '\ft 1(Ut'


_j
'~

l\ ltl ll 11 t l<e11,ra
1
~
U 11iversity
~ )

UNIVERSITY EXAMINATION 2017/2018

SCHOOL OF COMPUTING AND INFORMATICS


DEPARTMENT OF INFORMATION TECHNOLOGY

BBIT/BSC IT
REGULAR

UNIT CODE: BIT1208 UNIT TITLE: STRUCTURED


PROGRAMMING

DATE:AUGUST, 2018 MAIN EXAM TIME: 2 HOURS

INSTRUCTIONS: ANSWER ALL QUESTIONS IN QUESTION ONE AND ANY OTHER


TWO QUESTIONS

QUESTION ONE (30 Marks)

a) State FOUR advantages of structured programming. (4 Marks)

b) Define the following terms:, 'iD/\..1 c• ,,,\ r,> (•'\ , n t"'' L'f,n (10 Marks)
i. Algorithm , {~-! G\ 1•'J r, lll'

ii. Structured programming. LI,_ '" ,, _, , _, .... J


11
iii. Reserved words · "· 11 ,· • • • J '
. , I' '1
iv. Constant - v""""l:,'~ 1\••·-1 ii ' ,\
\•,(I L d I" I \.I' ",
V. Pointers - re, h 0,
~c /- c- J
' \'- , ~ \'·!
\_, (' \
c) Differentiate between :!±- and ..:..:. operator as po_stfix and prefix. (2 Marks)
1 , ;d.J C)i\( )1) l .,,.i.,· ~YI .ft !-\.,, ~-(fw{ " 1 'q
- - _0.)!.,h.,cJ ,r, r'll J ~-~,-J!,ll
1

dJ With an aid of a c program explain how CQnditiQO.al operators work. (3 Marks)

e) Name and explain THREE programming errors . (6 Marks)


\. ~-,,. I I I r.l 1. ' a.u r ...., (

f1 List THREE examples of high level languages. (3 Marks)


J c,.vr1
C,

Paper one Page 1


g) State two reasons for the shift from machine language
(2 Marks)
to assembly language.

QUESTION TWO (20 Marks)

a) Define an array. (2 Marks)

b) Write a C program to check whether a number entered by user is even or


odd . (4 Marks)

c) Write a c program that asks the user to enter an integer and this program
will generate the multiplication table up to 5. (5 Marks)
c.0 \"-h1 k C\ r',,,J'''"' h:J ,f o r'j root! 01 Cl ~UC!dn.h c.. f q,uei ~o•'l (cl n') a,~-0
QUESTION THREE (20 Marks)
~ o,I ~ f?

a) Draw and explain FOUR symbols used in a flowchart. O C:) C7 (8 Marks)


(>c "" 'hl,.::t\
L:,r , r ''j ,J~,,
b) State and explain the stages of program development lifecycle (pdlc) . 1 • ,,1

I ,. ~ '1 -:I OJ.J (I


(, brc.. ,,-1lv1rN"j ~~t h;J • ,. 1r-
1.._. I'~ ar'\ a1••1j -, ~!1' ~ 1!'.--1) (6 Marks) c. c:-d •nfl •· ·"••i -
£1 U,fl I l" 'L
r: JI(! , ~ I'" (
, 1, L
--1 n h J J d ,c.,_11••' )
u'v \ (II ,;j._,i1
I ti •-U< J,r ':'fT'l-'ni
c) Distinguish between 1st generation and 4th generation programming
languages. (4 Marks)

QUESTION FOUR (20Marks)

a) State two advantages of modular approach in programming .


(2 Marks)

b) Distinguish between each of the following pairs of stn1ctured programming


terms:
i. Pass by value and pass by reference (4 Marks)
ii. Source code and object code (4 Marks)

c) Outline three types of program documentation . (3 Marks)

d) Outline two uses of comments in a structured program . (2 Marks)

e) Write a program that will prompt the user to enter a number. The program
determines the square root of the number through a built-in function and
displays the result on the screen. (5 Marks)
/(
' 1/'v
J

Paper one Page 2


QUESTION FIVE (20 Marks)

itJI '\-
a) Explain the term nested -if control structure. I I 111 I I
1 11

! I( 1
l l j 1f (lf·!

t~< , I
(2 Marks)
, 1' \

b) Using a diagram describe the while loop. (3 Marks)

-~c) Write a C program that sums all integers from 10 to 70. Use
the for statement. 1 (5 Marks)
/; /
t I

d) The table below shows the charges applicable to different an¾ounts of water
consumed by clients in a particular town. /,., 1

Volume of water
Consumption in Ksh
consumed in M3
I. 0-16 200
'\ C
II . 10-20 350
111 . 20-30 500
IV. Over 30 1000

In addition to the consumption, the amount of the water bill will consist of a
standing charge of Ksh 200 and a sewerage fee equivalent to 20% of the
consumption.
Write a C program that prompts a user to enter the volume of water
consumed. The program then computes and outputs the amount of the
water bill. Use if.. . else control structure. (10 Marks)

I"' ~ ,,,.., .. , ' I I i


,\ I o, 1 I ,J ,l, 'J ;
,µ,~ 1~;ioo

l --1
I··'
1'

I , ~

!t

'l J'

Paper one Page 3

j
Mount Kenya '~ ~JUniversity
UNIVERSITY EXAMINATION 2016/2017

SCHOOL OF SCHOOL OF COMPUTING AND INFORMATICS


DEPARTMENT OF INFORMATION TECHNOLOGY

BIT/BBIT /BIT
VIRTUAL CAMPUS

UNIT CODE: BIT1208 UNIT TITLE: STRUCTURED PROGRAMMING

DATE: DECEMBER 2016 MAIN EXAM TIME: 2 HOURS

INSTRUCTIONS: ANSWER ALL QUESTIONS IN SECTION A AND ANY OTHER TWO FROM
SECTION B

SECT!ON A (Ccmpu!sory)

QUESTION ONE (30 marks)

a) List four Rules and Conventions for naming variables and constants in C.
[4 marks]
b) Explain using examples how to declare variable and initialize variable .
[4 marks]
c) Difference between union and structure. [4 marks]

d) Distinguish between gets() function and puts() with the help of an example.
[6 marks]
e) Use a flow chart to explain the three main program control structures
[6 Marks]
f) Differentiate between the following programming concepts [6 marks]
i. Loosely typed and strongly typed languages
ii. Pseudo code and Algorithms
· Linking and compiling

Paper One Page 1


SECTION B (Answer any two questions)

QUESTION TWO (20 marks)


j) Write a C program to multiply two matrices using multi-dimensional arrays .
[10 marks]
b) Implement a structure called Student in C with the following members.
\f,t-ru ~k ~ "!:- i [10 marks]
i. Student name C\1-t:ll' wl~ , t - t1<1tYU-
11' \- t1jlJtr"lhU" -tllJrl'I
ii . Registration Number
iii. Marks 11* \:; r(l t1 Ti-1-J j ;
rflO-: L
~ , 11.\C.'-
._r ./-u cfr 11 {- ..[
P' , h - PJ
QUESTION THREE (20 marks)

a) Write a program in C to find the area and perimeter of a circle. [10 marks]

b) Write a program in C to make a simple calculator to Add, Subtract, Multiply or


Divide Using switch .. .case. [10 marks]

~ UESTION FOUR (20 marks)

a) Using arrays , write a program to calculate average of 5 numbers


[10 marks]
b) Explain four characteristics of a good algorithm . [4 marks]

c) Develop a flowchart to accept the length and width of a rectangle and


calculate its area. [6 marks]

QUESTION FIVE (20 marks)

a) Using binary search write a program in C programming to search a given


number from a given list [10marks]

b) Write a Program to demonstrate Recursion in functions [6 marks]

c) State and explain any four categories of operators [4 marks]

Paper One Page 2

You might also like