Reputation: 27
Have a bit of a weird one and hopefully someone can help out.
The company I work for is doing an ad and we are looking for a Pascal programmer and we thought we'd incorporate some Pascal code into the ad itself. The only problem is we do not have any knowledge regarding Pascal. So after a little research the code we have come up with is:
Begin
Write('Enter in Name:');
readln(company);
Write('Enter in Australia:');
readln(country);
writeln;{new line}
writeln;{new line}
Writeln('Programming specialists:', 'company' ,'country');
Readln;
End.
And what we are trying to say is:
The person types in Name
And then types in Australia
And then on the screen appears Programming specialists: Name Australia
So is the syntax correct are we missing anything? like comma's or semi-colons etc
Upvotes: 0
Views: 1442
Reputation: 136401
you must remove the '
(single cuotes) character from the company and country variables, try this
var
company,country :string;
Begin
Write('Enter in Name:');
readln(company);
Write('Enter in Australia:');
readln(country);
writeln;{new line}
writeln;{new line}
Writeln('Programming specialists:', company,' ' ,country);
Readln;
End.
you can check this free ebook to learn more about the pascal syntax
Marco Cantù's Essential Pascal
Upvotes: 0
Reputation: 2548
That seems fine to me. I'm pretty fresh for programming in Pascal - did it in my college course only a couple of months ago. Take into account casablanca's comment though.
Also, make sure you have the top half of the program correct. Like so:
Program advert; {or any other pertinent name}
Uses crt; {This may be unneeded, but we were taught to always put it in}
Var
company, country: string;
Begin
Writeln('Enter in name');
{Writeln or write depends on how you want this to work - write will make the input on the same line (in a terminal) and writeln will make the input on line below}
Readln(company);
Write('Enter in Australia');
Readln(country);
Writeln;
Writeln;
Writeln('Programming specialists: ', company, ' ', country);
Readln;
End.
In regards to the Readln
at the end of the program, you might not need to use it. This essentially 'pauses' the program until the user presses the enter
key. I noticed that in Windows the command prompt had a habit of closing at the end, making a final readln
necessary, but in a Linux terminal, running the program from the terminal, this doesn't happen. Just a side note for you to consider.
Upvotes: 1
Reputation: 70701
It seems fine except for this line:
Writeln('Programming specialists:', 'company' ,'country');
You're printing the strings "company" and "country", but I assume you actually want the values entered by the user. So it should be:
Writeln('Programming specialists:', company ,country);
Upvotes: 2