0% found this document useful (0 votes)
13 views8 pages

CSC301 Practicals Examples

Uploaded by

Ifeoseme Joel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views8 pages

CSC301 Practicals Examples

Uploaded by

Ifeoseme Joel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

COURSE CODE: CSC 301

COURSE TITLE: Structured Programming


LECTURER:
Dr. Pius U. EJODAMEN
Ph.D., M.Sc., PGD(Edu), B.Eng. (Computer), DICE
MCPN, MNCS, MACM, SMIEEE, MTCN
Contact:
[email protected]
[email protected]
08050929297, 09135257551
Write a Pascal program to generate the display as shown.

Apply the following constraints:


(i) ‘YourSurname’ should be replaced with your actual Surname and implemented as
constant value. Interactively obtain a number from the user (500 in this case). Both
should be used in the statement to display as output.
(ii)Create a variable named result that first receives the result of the computation, then
displays the output: “The square root of 500 is result”.
Use appropriate in-code documentation technique to briefly explain how you are able
to calculate the square root correctly. (15marks)
QUESTION: Write a program to calculate the square root of a
number entry.
QUESTION: Write a program to generate the truth table for this
logic circuit.
QUESTION: Write a program to generate the truth table for this
logic circuit.
program logiccircuit; function NOTgate(x: boolean): begin
uses crt; boolean; clrscr;
var begin write('Enter the input value for A (0 for
A,B,C,D: boolean; if (x=TRUE) then NOTgate := FALSE FALSE, and 1 for TRUE): ');
i: 0 .. 1; else NOTgate := TRUE; A:=read_input(i);
end; write('Enter the input value for B (0 for
function ANDgate(x,y:boolean):boolean; FALSE, and 1 for TRUE): ');
begin function read_input(i:integer):boolean; B:=read_input(i)
if (x AND y) then ANDgate:=TRUE begin write('Enter the input value for C (0 for
else ANDgate:=FALSE; readln(i); FALSE, and 1 for TRUE): ');
end; if (i=1) then read_input:=TRUE C:=read_input(i);
else if(i=0) then read_input:=FALSE
function ORgate(x,y:boolean):boolean; else writeln('The output for AB is: ‘,
begin begin ANDgate(A,B));
if (x OR y) then ORgate:=TRUE write('Enter either 0 for FALSE, writeln('The output, z, is: ',
else ORgate:=FALSE; and 1 for TRUE: '); NOTgate(ORgate(ANDgate(A,B), C))));
end; read_input(i);
end; readkey;
end; end.
QUESTION: Write a program to report the grade for any
given score value.
program ScoreGrade; {Create program syntax/statement = 1mrk}
var
score: byte; {½mrk}
grade: String; {½mrk}

begin {½mrk}
write ('What is your score? '); {½mrk}
readln(score); {½mrk}
if (score<45) then grade:='F' {½mrk}
else if ((score>=45) and (score<50)) then grade:='D' {½mrk}
else if ((score>=50) and (score<60)) then grade:='C' {½mrk}
else if ((score>=60) and (score<70)) then grade:='B' {½mrk}
else if ((score>=70) and (score<=100)) then grade:='A’ {½mrk}
else grade:='out of range!'; {½mrk} {Use of Conditional statements = 3mrk}
writeln('Your score value is ', score, ' and your grade is ', grade); {1mrk}
readln;
end. {½mrk}

You might also like