Pascal Programming and Applications (CSCT2205)

Computer Science - COS

Semester: Second Semester

Level: 200

Year: 2015

Page 1
SCHOOL: H.T.T.T.C DEPARTEMENT: CS LECTURER(S): Dr. DADA Jean-Pierre
COURSE CODE: CSC125 COURSE TITLE: Pascal programming language OPTION: FCS100
DATE: July 15
th
, 2015 HALL: Amphi 650 TIME: 2 hrs NATURE: Exam
Instructions:…… NA…………..
Exercise 1: A company in charge of water resource in a village wants to build a water tower. The figure is
shown below. To calculate the volume of water that can contain the water tower, one suggests the formula:
󰇛
󰇜
, where V is the volume of water inside the
water tower;
and
are respectively the radius of
circles, H is the height of the water tower.
In a village without any calculator, you can use your
laptop to calculate the volume of the water tower.
1.1 Write an algorithm for this problem (3 marks).
1.2 Write an appropriate program using C language to solve
this problem (3 marks).
1.3 Simulate your program and represent what you should
have on the screen of your computer when the program will be running (4 marks).
Instructions: The values of H,
and
are inserted when the program is running. You should also limit the
number to be used to display on the screen the results (two numbers after the dot). For simulations, use these
values: ;
; H=2m and
. Th program should take into account that the volume is a
positive number.
Exercise 2: Let us assume that n=4. Execute the program below and design what will be displayed on the screen.
Don’t forget to give all the steps and correct errors if possible (4 marks)
program For_to_do;
var n,n1:integer;
fact:longint;
BEGIN
(* This program calculates the factorial of a number *)
writeln('');
writeln('Enter a number and validate please !');
readln(n);
fact:=1;
For n1:=1 to n do
begin
fact:=fact*n1;
REPUBLIC OF CAMEROON
Peace Work Fatherland
***********
THE UNIVERSITY OF BAMENDA
***********
HIGHER TECHNICAL TEACHER TRAINING
COLLEGE (H.T.T.T.C.) BAMBILI
***********
DIRECTORATE OF STUDIES
**********
P.O.BOX 39 BAMBILI
REPUBLIQUE DU CAMEROON
Paix Travail - Patrie
***********
UNIVERSITE DE BAMENDA
***********
ECOLE NORMALE SUPERIEURE
D’ENSEIGNEMENT TECHNIQUE
***********
DIRECTION DES ETUDES
**********
Tél: 33 05 10 69
www.schoolfaqs.net
Page 2
end;
writeln('----------------------------------------------------');
writeln('');
writeln('######### ',n,'! = ',fact);
writeln('');
END.
Exercise 3: Write a Pascal program able to calculate, the sum, the product and the division of two real numbers
with the conditions below (6 marks)
1) The main program will just call three sub programs named SUM(…); DIVISION(…) and PRODUCT(…).
2) all calculations are done in the sub programs
3) each sub program should return on result
4) The main program should enter from the screen the values of the two number and display on the screen, the
results
5) All necessary comments should be incorporated
www.schoolfaqs.net