stevengreen22
23-02-2011, 05:01 PM
Hi Guys,
Assignment 2...
idead being a different word is returned if integer is divisible by 3,5 or 15.
I've used 'whitespaces' in the write ln for spacing.
UNsure if this is the best method.
Would anyone mind giving it the once over and checking for any errors?
Thanks - the program does work as intended and displays ok, just a confirmation is what I'm after.
Thanks again.
program BUZZFIZZ(output);
uses crt;
const columncount = 5; {5 columns as 100 is div perfectly by 5}
columnwidth = 15; {either needs whitespaces or set in writeln}
Title: string = (' BUZZ FIZZ ');
By: string = (' By Steve Green ');
var i,j: integer;
ch: char;
begin {main program}
ClrScr;
writeln(Title);
writeln;
writeln(by);
writeln;
(* Hi, Welcome to etc etc, blaaaaaaaaaaaa, press return to*)
readln(ch);
for i := 1 to 9 do
begin
if ((i mod 5) =j) then
write(i,' = FIZZ ')
else
if ((i mod 3) =j) then
write(i,' = BUZZ ')
else
write(i,' = ')
end;
for i := 10 to 100 do
begin
if ((i mod 15)=int) then
write(i,' = BUZZ FIZZ ')
else
if ((i mod 5) =int) then
write(i,' = FIZZ ')
else
if ((i mod 3) =int) then
write(i,' = BUZZ ')
else
write(i,' = ')
end;
writeln;
writeln;
writeln ('Press Return to continue',ch);
read(ch);
end.
Assignment 2...
idead being a different word is returned if integer is divisible by 3,5 or 15.
I've used 'whitespaces' in the write ln for spacing.
UNsure if this is the best method.
Would anyone mind giving it the once over and checking for any errors?
Thanks - the program does work as intended and displays ok, just a confirmation is what I'm after.
Thanks again.
program BUZZFIZZ(output);
uses crt;
const columncount = 5; {5 columns as 100 is div perfectly by 5}
columnwidth = 15; {either needs whitespaces or set in writeln}
Title: string = (' BUZZ FIZZ ');
By: string = (' By Steve Green ');
var i,j: integer;
ch: char;
begin {main program}
ClrScr;
writeln(Title);
writeln;
writeln(by);
writeln;
(* Hi, Welcome to etc etc, blaaaaaaaaaaaa, press return to*)
readln(ch);
for i := 1 to 9 do
begin
if ((i mod 5) =j) then
write(i,' = FIZZ ')
else
if ((i mod 3) =j) then
write(i,' = BUZZ ')
else
write(i,' = ')
end;
for i := 10 to 100 do
begin
if ((i mod 15)=int) then
write(i,' = BUZZ FIZZ ')
else
if ((i mod 5) =int) then
write(i,' = FIZZ ')
else
if ((i mod 3) =int) then
write(i,' = BUZZ ')
else
write(i,' = ')
end;
writeln;
writeln;
writeln ('Press Return to continue',ch);
read(ch);
end.