Pascal Programming and Applications (CSCT2205)

Computer Science - COS

Semester: Second Semester

Level: 200

Year: 2015

Turbo Pascal programming language (Dr. J.P. DADA, University of Bamenda)
1
CA
Turbo Pascal programming language
Level 100
Exercise 1. Let us assume that n=5. 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.
program Factorial;
var n:integer;
fact,N1:longint;
BEGIN
(* This program calculates the factorial of a number *)
writeln('');
writeln('Enter a number and validate please !');
readln(n);
N1:=n;
fact:=n;
repeat
fact:=fact*(n-1);
n:=n-1;
until (n=1);
writeln('----------------------------------------------------');
writeln('');
writeln('######### ',n1,'! = ',fact);
writeln('');
END.
Exercice 2. 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.
RÉPUBLIQUE DU CAMEROUN
Paix-Travail-Patrie
UNIVERSITÉ DE BAMENDA
ECOLE NORMALE SUPERIEURE DE
L’ENSEIGNEMENT TECHNIQUE (E.N.S.E.T)
DE BAMBILI-BAMENDA
FAX : 33.05.10.69
DEPARTEMENT
DE GENIE INFORMATIQUE
REPUBLIC OF CAMEROON
Peace Work Fatherland
THE UNIVERSITY OF BAMENDA
HIGHER TECHNICAL TEACHERS TRAINING
COLLEGE (H.T.T.T.C) BAMBILI-BAMENDA
P.O. BOX 39, BAMBILI
TEL: 33.36.36.94
DEPARTMENT OF COMPUTER SCIENCE
www.schoolfaqs.net
Turbo Pascal programming language (Dr. J.P. DADA, University of Bamenda)
2
In a village without any calculator, you can use your laptop to calculate the volume of the
water tower.
a) Write an algorithm for this problem
b) Write an appropriate program using C language to solve this problem
c) Simulate it and represent the screen of the Laptop when the program is running.
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.
www.schoolfaqs.net