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

Pascal Programs Notes

The document contains 10 programs written in Pascal programming language. The programs demonstrate various Pascal concepts like variables, constants, input/output statements, if-then conditional statements, case statements, for loops and repetition statements. Program 4, 5, 6 demonstrate formatted output while program 7, 8, 9 demonstrate mathematical operations, variables and input statements. Program 10 uses character and string variables. Program 11 and 12 show if-then conditional logic. Program 13 demonstrates a simple decision making logic using if-else. Program 14-18 provide pseudo code for programs to check data types, even-odd, grading system using if-else and case statements. Program 19-21 discuss repetition statements like for loops.

Uploaded by

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

Pascal Programs Notes

The document contains 10 programs written in Pascal programming language. The programs demonstrate various Pascal concepts like variables, constants, input/output statements, if-then conditional statements, case statements, for loops and repetition statements. Program 4, 5, 6 demonstrate formatted output while program 7, 8, 9 demonstrate mathematical operations, variables and input statements. Program 10 uses character and string variables. Program 11 and 12 show if-then conditional logic. Program 13 demonstrates a simple decision making logic using if-else. Program 14-18 provide pseudo code for programs to check data types, even-odd, grading system using if-else and case statements. Program 19-21 discuss repetition statements like for loops.

Uploaded by

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

Program 1 Program 4

Program PrintText; Program Text_Format;


Uses crt; Uses crt;
Begin Begin
clrscr; clrscr;
writeln('ICT' ); writeln('Hello':30);
writeln('Garade 11' ); writeln('How':30);
writeln('Pascal writeln('Are':30);
Programing'); writeln('You':30);
readln; readln;
End. End.

Program 2
Program 5
Program Write_and_Writeln;
Uses crt; Program Unformatted_reals;
Begin Uses crt;
clrscr; Begin
writeln('Hello'); clrscr;
writeln('How'); writeln('100.25 => ',100.25);
writeln('Are'); writeln('0.3 => ',0.3);
writeln('You'); writeln('4.0 => ',4.0);
write('Hello '); writeln('-45.56E5 => ',-45.56E5);
write('How '); writeln('0.56E-5 => ',0.56E-5);
write('Are '); readln;
write('You '); End.
readln;
End.
Program 6
Program Formatted_reals;
Program 3 Uses crt;
Program Print_integer; Begin
Uses crt; clrscr;
Begin writeln(100.25:10:2);
clrscr; writeln(0.00356:10:4);
writeln(100); writeln(4.0:10:3);
writeln(+23); writeln(-45.56E5:10:2);
writeln(-12); writeln(0.56E-5:10:2);
writeln(0); writeln(25.25:10:2,12.253:10:3);
readln; readln;
End. End.
[Type here] [Type here] [Type here]
Program 7 Program 9
Program Math; Program Inputs;
Uses crt; Uses crt;
Begin var Mark,Total:integer;
clrscr; Avg:Real;
Writeln('100 devided by 5 is = ',100/5); Begin
Writeln('5 squared is = ',sqr(5)); clrscr;
Writeln('Square root of 100 is = ',sqrt(100)); Total:=0;
Writeln('Balance of 10 devided by 3 is = ',10 mod 3); writeln('Input Marks for Subject 1');
Writeln('Quotient of 10 devided by 3 is = ',10 div 3); readln(mark);
Writeln('Rounded value of 5.635 is = ',round(5.635)); Total:=Total+Mark;
Writeln('For MOD & DIV number must be integer'); writeln('Input Marks for Subject 2');
readln; readln(mark);
end. Total:=Total+Mark;
writeln('Input Marks for Subject 3');
readln(mark);
Total:=Total+Mark;
Program 8
Avg:=Total/3;
Program Variables; writeln('Total is ',Total);
Uses crt; writeln('Average is', Avg:6:2);
varMath,ICT,Eng,Total:integer; readln;
Average:Real; End.
Begin
clrscr; Program 10
Math:=75;
ICT:=62;
Program Char_String;
Eng:=65;
Uses crt;
Total:=Math+ICT+Eng;
varch:char;
Average:=Total/3;
st:string;
writeln('Total is ',Total);
Begin
writeln('Average is', Average:6:2);
clrscr;
readln;
write('Press any character');
readln(ch);
write('Type your name');
readln(st);
How do you modify the above program to writeln('You Press ' ,ch);
writeln('Your name is ',st);
get the following output?
readln
Marks Sheet End.
==========

Math 75
ICT 62
English 65
Totalhere]
[Type 202 [Type here] [Type here]
Average 67.33
Program 11

Program if_then; Write programs for the following


Uses crt;
Program 14
VarAmt:real;
Const Dis=0.05; To check whether the given character
Begin is an alphabetic character or not.
clrscr;
writeln('Entet your amoynt'); Program 15
readln(Amt); To check whether the given number
ifamt>1000 then is odd or even.
amt:=amt-amt*dis;
writeln('Your Amount is ',amt:5:2); Program 16
readln
End. Pseudo code

Program 12 Begin
Read marks
Pseudo code If marks >=75 then
Grade=”A”
Begin Else if marks >=65 then
Read math marks Grade=”B”
Read science marks Else if marks >=50 then
if math marks >=50 and science marks>=50 then Grade=”C”
display “You are selected” Else if marks >=35 then
else Grade=”S”
display “You are not selected” Else
Endif Grade=”W”
End If
Program 13 display Grade
End
Pseudo code
Program Cases;
Begin Program 17
Uses crt;
Read the price of an apple
var
if price >=50 then
Grade:Char;
display “Price is too high”
Begin
display “Don’t buy today”
clrscr;
else
write('Entet your Grade ');
display “Price is OK”
readln(Grade);
display “You may buy”
case grade of
Endif
'A':Write('Excelent');
'B':Write(' Very Good ');
Program 18 'C':Write(' Good');
Write a program using CASE statement to print 'S':Write(' Study hard ');
[Type here] [Type here] [Type
'W':Write(' Try it again '); here]
the number of days of the month when the
number of the month is given. else
write('Error in grade');
Program 19 Write the program 16 using CASE statement.

Repetition Statements

Program 20 Program 30

Program ForToDo; How do you print the five times


Uses crt; table as given below?
var
i:integer; 5x1 = 5
Begin 5x2 = 10
clrscr; .
for i:= 1 to 10 do .
writeln('* '); 5x12= 60
readln;
for i:= 1 to 10 do
write('* '); Program 31
readln;
How do you print the following pattern?
End.
1
12
Program 21 123
Program ForToDo; 1234
Uses crt; 12345
var
i:integer; Program 32
Begin
clrscr; Can you modify the above program 30
for i:= 1 to 10 do to get the multiplication table?
writeln('* * * * * * * * * *');
readln;
End.

Write programs for the following.


22.To print 1 to 10 numbers.
23.To print the English alphabet.
24.To print the numbers from 20 to 10.
25.To print the odd numbers up to 20.
26.To print the total & average of first ten numbers.
27.To print the total & average of five subjects.
28.To add even numbers from any given ten numbers.
29.To read and store the numbers for, any given number of times and
print the total & average.
[Type here] [Type here] [Type here]
Program 33 Arrays
Program dowhile; Program 37
Uses crt;
var Program MyArray1;
x:integer; Uses crt;
Begin var
clrscr; M:array[1..5] of integer;
x:=1; i:integer;
while x<=10 do Begin
begin clrscr;
writeln('ICT'); for i:= 1 to 5 do
x:=x+1; begin
end; writeln('Enter marks');
readln; readln(m[i]);
End. end;
for i:= 1 to 5 do
writeln(m[i]);
readln;
Program 34 end.

Program RepeatUntil;
Uses crt;
var Program 38
x:integer;
Begin program ArrayTotal;
clrscr; Uses crt;
x:=1; var
repeat M:array[0..4] of integer;
writeln('ICT'); i,Tot:integer;
x:=x+1; Begin
until x>10 ; clrscr;
readln; Tot:=0;
End. for i:= 0 to 4 do
begin
write('Enter marks');
Program 35
readln(m[i]);
Pseudo code end;
for i:= 0 to 4 do
Begin tot:=tot+m[i];
Total=0 writeln('Total is ',tot);
Counter=0 readln;
While counter<=10 End.
Read marks
Add marks to the total
Add one to the counter Program 39
End while Find the maximum number from
Calculate the average the given 10 numbers.
Display the average
[Type here]
End [Type here] [Type here]
Program 36. Rewrite the above program
using the REPEAT UNTIL statement.
Program 40
Write a program to read and store your name letter by letter and then print the name.
Functions and Procedures
Program 41 Program 42
Program Functions; Program Procedures;
Uses Crt; Uses Crt;
var N1,N2,Answer: Integer; var N1,N2,Ans: Integer;

function Add( i, j:Integer): Integer; Procedure Add( i, j:Integer; var res:integer);


Begin Begin
Add := i + j; res := i + j;
End; Writeln('Total ',res);
Begin End;
clrscr; Begin
writeln('Enter Two Numbers '); clrscr;
readln(N1,N2); writeln('Enter two Numbers ');
Answer := Add(N1,N2); readln(N1,N2);
Writeln('Total ',answer); Add(N1,N2,Ans);
readln; readln;
End. End.

Program 43 Program 44
Program Functions; Program Procedurs;
Uses crt; Uses crt;
var var
Num:integer; Num:integer;
Res:Boolean; Ans:Boolean;
Function IsOdd(x:Integer): boolean; Procedure IsOdd(x:Integer; var
res:boolean);
Begin
if x mod 2<>0 then Begin
IsOdd:=true if x mod 2<>0 then
else res:=true
IsOdd:=false; else
End; res:=false;
Begin if Res=true then
clrscr; write('Odd Number')
write('Entet a Number '); else
readln(Num); write('Even Number');
IsOdd(Num); End;
Res:=IsOdd(Num); Begin
if Res=true then clrscr;
write('Odd Number') write('Entet a Number ');
else
[Type here] [Type here]readln(Num); [Type here]
write('Even Number'); IsOdd(Num,ans);
readln; readln;
45.Write a program to output the maximum number from given three numbers.
46.Write a program to print whether the triangle is scalene, isosceles or
equilateral when three sides are given.
47.Write a program to convert between Celsius and Fahrenheit temperatures.
9 5
F = C x 5 + 32 C = (F-32) x 9

48.Write an interactive program to calculate two numbers. The program should


present the user with the menu given below.
Calculation
========== 49. Write a program to get the
1. Addition following output.
2. Subtraction
3. Multiplication
4. Division
1
5. Exit 2 3 2
Enter Your Choice : 3 3 4 5 4 3
Insert 1st number: 2 4 5 6 7 6 5 4
Insert 2nd number: 4
Result is : 8.00 5 6 7 8 9 8 7 6 5

Any key to continue …….

50.Write a program to read & store the numbers and print the total & average by
terminating the program if zero has to be entered.
51.Write a program to print the Fibonacci sequence from 0 to 1000
Note. The Fibonacci sequence is a series of numbers where a number is
found by adding up the two numbers before it.
52.Write a program to find the factorial of given positive number.
53.Write a program to consider the problem of determining whether the number
given, is aPrime number.
54.Write a program to read and store 10 different values of integer and
a. Store the above values after multiplying by 3
b. Store the values after dividing by 3
c. Store the remainder after dividing by 3

[Type here] [Type here] [Type here]


55.Write a program to read and store 10 different integer numbers and sort them
in ascending order.
56.Write two programs using Functions & Procedures to check whether the given
character is a digit or not.

The Fibonacci sequence is a


series of numbers where a
number is found by adding up
the two numbers before it.
Starting with 0 and 1, the
sequence goes 0, 1, 1, 2, 3, 5,
8, 13, 21, 34, and so forth.

[Type here] [Type here] [Type here]

You might also like