XtGem Forum catalog
 

QUICK HINT: ANSWERS ARE BELOW THE QUESTIONS

 
  A Program to arrange sets of students scores and their average in ascending order (Bubble sort)
A program to compute the AP and GP of some data.
A Pascal program to read 50 inputs find their average and get the Highest of the numbers.
A program to read in the data of a student and get or calculate his age.
A program to calculate the allowance on a vehicle given the distance, engine size and rate of pay.
A program to find the area of a circle.
A program to find the area of several circle given the number of the circles.
A program to find the sum and average of "n" number of integers.
A program to arrange a set of numbers in ascending order (WITHOUT ARRAY) using FOR statement.
A program to read values into array A and divide it by corresponding values of array B with each answers outputs.
A program to calculate the average of N numbers using FOR statement.
Using function subprogram, a program to find the area of a circle.
Using FUNCTION subprogram, a program to find the FACTORIAL of positive integer.
A program to find the fibonacci series of an NTH value.
A program to print the sequence of odd numbers between 1 and 500 using FUNCTION in PASCAL.
A program to calculate the greatest common divisor of two given integers using PASCAL.
A program to calculate the GPA of a student offering 9 courses with course unit differences.
A program to find the GREATEST of two numbers (IF STATEMENT).
A PASCAL program to determine if an integer input is greater than zero.
A program to find the root of a QUADRATIC EQUATION and determine if it has real root.
 
 

A Program to arrange sets of students scores and their average in ascending order (Bubble sort)
program ascendingorder(input,output);
{program to arrange a set of numbers in ascending order}
uses wincrt;
const
lo=1;
hi=10;
type
intarraytype=array[lo..hi] of integer;
procedure insertion_sort(var intarray:intarraytype;n:integer);
var i,j,temp:integer;
begin
for j:=1 to n do
begin
temp:=intarray[j];
{move all larger than key to the right}
i:=j-1;
while((i>=1)and (intarray[i]>temp)) do
begin
intarray[i+1]:=intarray[i];
i:=i-1;
end;
{insert current value into proper place}
intarray[i+1]:=temp;
end;
end;
procedure display_array(intarray:intarraytype;n:integer);
var i:integer;
begin
for i:=1 to n do
write(intarray[i]:4);
writeln;
writeln;
end;
var
nums:intarraytype;
nums_length,k:integer;
begin
writeln(' input the values you want to sort:');
for k:=1 to 10 do
begin
readln(nums[k]);
end;
nums_length:=10;
writeln('values to be sorted');
display_array(nums,nums_length);
insertion_sort(nums,nums_length);
write('values in ascending order:');
display_array(nums,nums_length);
end.

 
  A Pascal program to read 50 inputs find their average and get the Highest of the numbers.
Program averagensum(input,output);
Uses wincrt;
Var count,n,x,sum, a, largest: integer;
Average:real;
Begin
a:=0;
Sum:= 0;
Write('How many numbers?');
Readln(n);
For count := 1 to n do
Begin
Write('Input number: ');
Readln(x);
if x > a then a := x else
a:=a;
Sum:= sum + x;
Average := sum/n ;
end;
largest:=a;
Writeln(' sum =',sum);
Writeln(' Average = ',average:4:2);
writeln ('Largest of the number=', largest);

End.

 
  A program to arrange a set of numbers in ascending order using FOR statement.
program ARRANGE_ASC;
{A program to arrange a set of numbers}
uses wincrt;
const m=5;
type
stud=array[1..m] of integer;
procedure insert(var num:stud; n:integer);
var
i,j,temp:integer;
begin
for j:=1 to m do
begin
temp:=num[j];
i:=j-1;
while (i>=1) and (num[i]>temp) do
begin
num[i+1]:=num[i];
i:=i-1;
end;
num[i+1]:=temp;
end;
for i:=1 to m do
write(num[i]);
end;
var
no:stud;
test,largest,no_l,k:integer;
begin
writeln('Enter the scores of each student:');
for k:=1 to m do
begin
readln(no[k]);
end;
test:=0;
no_l:=m;
writeln('The sores in ascending order are');
insert(no,no_l);
writeln;
if (no[k]>test) then test:=no[k];
largest:=test;
writeln('The largest score is:',largest);
end.
 
 

A program to read in the data of a student and get or calculate his age.
(*A program to read in the data of a student and get or calculate his age*)
Program Ages (input,output);
uses wincrt;
var age:integer;
name :string;
begin
Writeln('What is your name?');
read(name);
writeln('How old are you?');
read(age);
case age of
0..12:write(name ,' you are a child');
13..19:write(name,' you are a teenager');
20..40:write(name,' you are a youth');
else
write(name,' you are very old');
End;
End.

 
  A program to calculate the allowance on a vehicle given the distance, engine size and rate of pay.
program weekly_allowance;
{A program to calculate the allowance on a vehicle given the distance, engine size and rate of pay}
uses wincrt;
var
size,allowance,distance,rate:integer;
begin
write('Supply the size :');
readln(size);
write('Supply the distance :');
readln(distance);
if (size<2000) then rate:=100
else
rate:=150;
allowance:=distance*rate;
writeln('The allowance per week is :',allowance);
end.
 
  A program to find the area of a circle
PROGRAM CIRCLE (INPUT,OUTPUT);
USES WINCRT;
VAR AREA, RADIUS: REAL;
BEGIN
READ(RADIUS);
AREA:= 3.142 * SQR(RADIUS);
WRITELN('THE AREA IS',AREA);
END.
 
  A program to find the area of several circle given the number of the circles (USING PROCEDURAL SUBPROGRAM).
program sevcir (input,output);
uses wincrt;
var n,count:integer;
area,radius:real;
procedure mopo(var r,a:real);
const pi=3.14159;
begin
a:=pi*sqr(r);
end;
begin
write('supply the number of circles:');
readln(n);
for count:=1 to n do
begin
write(' radius=');
read(radius);
mopo(radius,area);
writeln('Area=',area:8:3)
end;
end.
 
     
  Go back Home Questions LATTERTALKSAM INC.  
     
Tobi pascal (c) 2011 - Eternity