Q;Write a program which reads a sequence of characters. Assume that there are exactly two asterisks (*) in the sequence. Your program should display the number of characters between these asterisks. Asterisks will not be counted. 
program Q1 (input,output);
var
ch:char;
count:integer;
begin
repeat
read(ch)
until ch='*';
count:=0;
repeat
read(ch);
if ch<>'*' then
count:=count+1
until ch='*';
writeln('There are ',count,' characters between asterisks')
end.
 
Q: Write a program which reads 10 integers. The program should find and display the integer which is closest to 50. 
Examples:
33 98 65 11 0 -5 007 11 120 99
The required number is 65
 
8 21 44 65 1 -67 2 7 370 82
The required number is 44
 
76 50 49 -50 65 51 25 5 909 404
The required number is 50
 
 
program Q(input,output);
var
num,n,i : integer;
begin
num:=-maxint;
for i:=1 to 10 do
begin
read(n);
if abs(n-50) < abs(num-50)
then num:=n
end;
writeln('The number closest to 50 is ' ,num)
end.
 
Q : In the context of
const
pi = 3.141592654;
var
a:real; i:integer;

a) Write the necessary Pascal statements to calculate and display the value of the following mathematical expression: 

An equation
sum:=0;
for i:=1 to n do
sum:=sum + exp (-sin(pi/7) / cos(pi/7)*ln(i)) / abs(sin (pi/7) - sqrt (a/9));
writeln(sum:9:3);
{Assume "sum" is a previously declared real variable.}
b) What is the value of a after the following statement ?

a:=ord(37 div 3 mod 4 <=2) * 5.3 + 20*3/4/5; A: 8.3

 
A First Look A First Look at Pascal Basic Input/Output Identifiers & Types
Constants Standard Functions If..Then Statement Case Statement
Repetitions Procedures and Functions Enumerated /Subrange Types Sets
I/O, Text Files Arrays Records Recursion
Pointer How to Debug Previous Exam Questions Advanced
ASCII Code Table Homepage University Homepage Computer Engineering Dept.