You are on page 1of 1

UNIVERSITY OF PERADENIYA

DEPARTMENT OF STATISTICS AND COMPUTER SCIENCE


MID SEMESTER EXAMINATION (SEMESTER I) - 2011/2012
CS104-STRUCTURED ORIENTED PROGRAMMING (1-CREDIT)
Time allowed: 90 min Answer A questions
INSTRUCTIONS:
Answer to each question; C file, must be save with !our re"istration number an the
question number# $%": S&'((()&a#C, S&'((()&b#C an S&'((()*#C+
1. It is required to calculate the student average mark for CS104 examination. Write down a C
program to achieve this task ! using a repetitive structure "loop#. $ssume that there are n
students. %our program must process onl! valid inputs. &hat is marks in etween 0 and 100.
'ewrite !our program ! using a different loop.
"() marks#
(. It is required to generate one of the following three patterns according to the user selection.
*evelop a C program that facilitate the selection of a pattern ! entering a+ or c. &hen the
program generates and displa!s the appropriate pattern. $ssume that option a+ and c
represents pattern 1+ pattern( and ,attern - respectivel!.
%our program must generate an error message when an incorrect option is selected.
,attern 1 ,attern ( ,attern -
1
( (
- - -
4 4 4 4
) ) ) ) )
. . . . . .
/ / / / / / /
0 0 0 0 0 0 0 0
(/) marks)
1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
5 6 7 8 9 8 7 6 5
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*

You might also like