pascal help

Hi hi.
I'm in need of help. I'd like to make this program but doesn't really seem to work.
I'll try to explain what I want.
The program gives a random number between 1-100, and you have to write another one(stintless) and we need the square(smaller number to the power two) of the smaller number.
(using function)

program test;
uses crt,
var
a,b:integer;
function square(szam1,szam2:integer) : integer;
begin
if szam1<szam2 then write(sqr(szam1))
else write(sqr(szam2));
end;
begin
clrscr;
randomize;
b:=random(101); write(a);
writeln;
writeln('2nd number:'); readln(b);
write('smaller number to the power two:', square(??);
readln;
end.
I tried to write square(a,b) then it gives the result of both number.
I hope you understand this way of explanation :D Sorry for my english :)
Let me know what's wrong there :(
Comments
21
stop pushing my bustjournal down
what does 'stintless' mean
It means there* are no localizations between values. (I mean no matter if its 0-1000, or 50-60 smth like that)
Parent
First you set b to be a random number between 1-100, then you do
writeln('2nd number:'); readln(b);, letting the user overwrite the value of b, doesnt make any sence.

a:=random(101);
writeln('2nd number:'); readln(b);
write('smaller number to the power two:', square(a,b);

Been very long since I did any programming in Pascal, so Im not 100% sure it will work
why do you use pascal? its like driving grandprix with a beetle :(
Pascal was created to be an easy language for people who's never done any programming before so that they can learn the basics and then move on to something else
Parent
you hit the nail on the head!
Parent
program test;
uses crt;
var
a,b:integer;
procedure square(szam1,szam2:integer);
begin
if szam1<szam2 then write(sqr(szam1))
else write(sqr(szam2));
end;
begin
clrscr;
randomize;
a:=random(101);
write(a);
writeln;
writeln('2nd number:'); readln(b);
write('smaller number to the power two:');
square(a,b);
readln;
end.

Edit: Im awesome, except for the small detail that I forgot the syntax for functions so I used a procedure instead :(
I tired square(a,b) but it doesn't want to work for me. I mean if I give 10 as a number and the program gives 15 itself, the result should be 100. But this gives me smth like that: 231122.
Parent
The code in my comment above this one works, I've tryed it myself.

If you're still using your old code I think the problem might be that you never set a value for a, which results in something random.
Parent
I've tired it with function but it doesn't work :D I'll try it with procedure.
Thanks mate!
Parent
fake account, fake picture, fake sex, fake age?
Parent
No, no, no and no.
Parent
so your a 16 yr old female coder?
Parent
Coder, no.

But everyone in my school read some basic programming.

And why would it be so strange if I were a girl who was interested in computer stuff, like programming?
Parent
not strange, just unusual :P certainly in ireland anyway
Parent
got it btw
in fuction i had to set this:
if szam1<szam2 then square:=sqr(szam1)
else square:=sqr(szam2);**
:))
Parent
Ah, makes sence, ty
Parent
code without the C style braces loooks so fucking disgusting. yuck.
idd ;S terrible to understand
Parent
With proper indentation its the same, just replace begin with { and end; with }
Parent
Back to top