1readln (a, b, c);
2s := (a + b + c)/2.0;
3area := sqrt(s * (s - a)*(s-b)*(s-c));
4writeln(area);
1program addFiledata;
2const
3 MAX = 4;
4type
5 raindata = file of real;
6
7var
8 rainfile: raindata;
9 filename: string;
10procedure writedata(var f: raindata);
11
12var
13 data: real;
14 i: integer;
15
16begin
17 rewrite(f, sizeof(data));
18 for i:=1 to MAX do
19
20 begin
21 writeln('Enter rainfall data: ');
22 readln(data);
23 write(f, data);
24 end;
25
26 close(f);
27end;
28
29procedure computeAverage(var x: raindata);
30var
31 d, sum: real;
32 average: real;
33
34begin
35 reset(x);
36 sum:= 0.0;
37 while not eof(x) do
38
39 begin
40 read(x, d);
41 sum := sum + d;
42 end;
43
44 average := sum/MAX;
45 close(x);
46 writeln('Average Rainfall: ', average:7:2);
47end;
48
49begin
50 writeln('Enter the File Name: ');
51 readln(filename);
52 assign(rainfile, filename);
53 writedata(rainfile);
54 computeAverage(rainfile);
55end.
1Sr.No Control Statement & Description
21 break statement
3Terminates the loop or case statement and transfers execution to the statement immediately following the loop or case statement.
4
52 continue statement
6Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.
7
83 goto statement
9Transfers control to the labeled statement. Though it is not advised to use goto statement in your program.
1type
2days, age = integer;
3yes, true = boolean;
4name, city = string;
5fees, expenses = real;
1type
2 Rptr = ^real;
3 Cptr = ^char;
4 Bptr = ^ Boolean;
5 Aptr = ^array[1..5] of real;
6 date-ptr = ^ date;
7 Date = record
8 Day: 1..31;
9 Month: 1..12;
10 Year: 1900..3000;
11 End;
12var
13 a, b : Rptr;
14 d: date-ptr;
1VELOCITY_LIGHT = 3.0E=10;
2PIE = 3.141592;
3NAME = 'Stuart Little';
4CHOICE = yes;
5OPERATOR = '+';
1Sr.No Call Type & Description
21 Call by value
3This method copies the actual value of an argument into the formal parameter of the subprogram. In this case, changes made to the parameter inside the subprogram have no effect on the argument.
4
52 Call by reference
6This method copies the address of an argument into the formal parameter. Inside the subprogram, the address is used to access the actual argument used in the call. This means that changes made to the parameter affect the argument.
1program DataFiles;
2type
3 StudentRecord = Record
4 s_name: String;
5 s_addr: String;
6 s_batchcode: String;
7 end;
8
9var
10 Student: StudentRecord;
11 f: file of StudentRecord;
12
13begin
14 assign(f, 'students.dat');
15 reset(f);
16 while not eof(f) do
17
18 begin
19 read(f,Student);
20 writeln('Name: ',Student.s_name);
21 writeln('Address: ',Student.s_addr);
22 writeln('Batch Code: ', Student.s_batchcode);
23 end;
24
25 close(f);
26end.