Draw a flowchart to find the largest of three numbers x, y and z.
Write a Pascal Program to find the largest of three numbers x, y and z.
Method I
program FindMaxFrom3;
var
x,y,z,max :integer;
begin
writeln('Enter a Number?');
read(x);
writeln('Enter a Number?');
read(y);
writeln('Enter a Number?');
read(z);
if (x > y) then
if (z > x) then
max:=z
else
max:=x
else
if (z > y) then
max:=z
else
max:=y;
writeln('Maximum number is :');
write(max);
readln;
end.
Method II
program FindMaxOf3num;
var
x,y,z,max :integer;
begin
writeln('Enter a Number?');
read(x);
writeln('Enter a Number?');
read(y);
writeln('Enter a Number?');
read(z);
if (x > y) then
max:=x
else
max:=y;
if (z >max) then
max:=z;
writeln('Maximum number is :');
write(max);
readln;
readln;
end.
or
We can use a Pascal procedure to find the maximum number of given three numbers as input parameters and maximum number as output parameter . Below Pascal program shows that
program findMaximum;
var
m:integer;
procedure findMax(x, y, z: integer; var max: integer) ;
begin
if (x > y) then
max := x
else
max := y;
if (z > max) then
max := z;
end;
begin
findMax(20,300,120,m);
writeln(m);
readln;
end.
or
We can use a Pascal function to find maximum number from given three numbers by passing three numbers as input parameters and return the maximum number as return value. Below Pascal program shows that
program findMaximumFunction;
var
m:integer;
function findMax(x, y, z: integer):integer ;
var
max:integer;
begin
if (x > y) then
max := x
else
max := y;
if (z > max) then
max := z;
findMax:=max;
end;
begin
m:=findMax(20,300,120);
writeln(m);
readln;
end.

This is a great example of combining flowcharts with Pascal programming to solve a practical problem like finding the largest of three numbers! The flowchart’s logic helps in understanding the decision-making process visually, which is especially helpful for beginners learning structured programming. If you're looking for an intuitive way to create and refine flowcharts for problems like this, Creately flowchart maker can be a great tool to explore. It simplifies the design process while adhering to standard flowcharting conventions!
ReplyDelete