• We've upgraded our forums. Please post any issues/requests in this thread.

Basic Pascal

Joined
Sep 15, 2009
Messages
2,076 (0.69/day)
Likes
379
System Name Omen
Processor i7-4710HQ
Cooling Dual fan/heatpipe
Memory 16GB
Video Card(s) 4GB GTX 860M
Storage 256GB PCIE SSD/256GB PNY UHS-1 SD Card
Display(s) 15.6' 1080P
Case Aluminium
Audio Device(s) Onboard
Power Supply Brick
Software Win 10
#1
Hi guys. At school we just started some pascal programming and our teacher has told us to try do it on our own at first. I'm 15 and have no background in programming. These are some questions we were given.

All to be done with pascal! In bold is what I have done.


1 The program should ask for the user’s personal details, including fi rst name, family name, birth date, favourite singer, favourite movie actor, then display details on the screen like this:
First name:
Family name:
Birth date:
Favourite singer:
Favourite movie actor:
(Have not answered this yet)

1 Write an assignment statement that assigns your own name to a string variable and prints out the message ‘Hello, yourname!’

VAR
fname : string;
Write(“What is your name?”);
Readln (fname);
Write (“Hello “ ,fname, “!”)


2 Write an assignment statement that assigns the first letter of both your first and second names to character variables and then prints out a greeting using your initials only: ‘Hello, XX!’

VAR
fname: string;
sname: string;
Write(“What is you first and last name?”);
Read

This is where I am confused. :eek:

And this I have not yet gotten up to.
3 Write an assignment statement that assigns your birth date to a date variable. Next write a function which calculates the number of days that have passed from the birthdate to the present and finally prints out the
message ‘Hello, your name! You are xx days old!’

And help would be greatly appreciated! :D
 
Joined
Jul 23, 2011
Messages
1,555 (0.67/day)
Likes
1,459
Location
Kaunas, Lithuania
System Name Eternal WIP ][ HP ProLiant server blade
Processor AMD FX-8320 @ 4.4/4.1 GHz ][ 2x Intel Xeon L5520 @ 2.27GHz
Motherboard Asus Crosshair V Formula-Z ][ -
Cooling Corsair H55 ][ Stock
Memory 2x4GB Kingston HyperX Genesis @ 1866MHz ][ 4x4 GiB Hynix @ 1333 MHz; ECC on
Video Card(s) 2x MSI GeForce GTX 770 DirectCU II OC ][ None
Storage 1TB WD Black + 1.5TB WD Green + 750GB Samsung + 64GB OCZ Agility 4 ][ 3x 1 TB Hitachi
Display(s) Asus VG278H + Asus VH226H ][ None
Case Antec Nine Hundred ][ it's a server blade, lol
Audio Device(s) Supreme FX II (Integrated); Using optical S/PDIF output ][ none
Power Supply Corsair AX1200i ][ [stock]
Software Gentoo Linux ][ Linux Mint 16
Benchmark Scores 65970 BogoMIPS. Ha. Ha. Ha. >=|
#2
ooh! I ditched this B&D language as soon as I passed the CS exam / graduated from highschool. Hehe!

Nonetheless, I will try to help You, given I manage to remember it ;]
 
Joined
Sep 15, 2009
Messages
2,076 (0.69/day)
Likes
379
System Name Omen
Processor i7-4710HQ
Cooling Dual fan/heatpipe
Memory 16GB
Video Card(s) 4GB GTX 860M
Storage 256GB PCIE SSD/256GB PNY UHS-1 SD Card
Display(s) 15.6' 1080P
Case Aluminium
Audio Device(s) Onboard
Power Supply Brick
Software Win 10
#3
ooh! I ditched this B&D language as soon as I passed the CS exam / graduated from highschool. Hehe!

Nonetheless, I will try to help You, given I manage to remember it ;]
Thanks! I know for the second one, Left (1) should be used. But I'm not sure how to word it out. :eek:
 
Joined
Jan 2, 2012
Messages
1,016 (0.47/day)
Likes
1,420
Location
Indonesia
Processor AMD Ryzen R7 1700X @ 3.9 Ghz
Motherboard BIOSTAR X370GT7
Cooling Cryorig H5 Universal dual fan mode
Memory Team T-Force Night Hawk DDR4-3200 2x16 GB
Video Card(s) Inno3D GTX 1080 GAMING OC
Storage 512 GB Samsung 850 Pro + 3 x 2 TB WD Blue
Display(s) LG 27MB85Z
Case Fractal Design Define R5 Black
Power Supply Seasonic Prime 750W
Mouse Logitech G502
Keyboard TX-CP (Ergo Clear 68g) | KBParadise V80 (Matias Quiet Click)
Software Windows 10 version 1607 x64 + Ubuntu 16.04
#4
Every string variable is an array of chars.

Example :
You have fname variable, containing "Edward".
So fname[1] = "E", fname[2] = "d", fname[3] = "w", and so on.

Something like this :

PHP:
uses crt;

var
fname, sname : string;

begin
writeln("What is your first name?");
readln(fname);
writeln("What is your last name?");
readln(sname);
writeln("Hello, ",fname[1], sname[1], "!");
end.
or you can use leftstr(string,n), this function return a string from the leftmost position.

Example :
You have fname variable, containing "Edward".
leftstr(fname,1) will return "E",
leftstr(fname,3) will return "Edw",
leftstr(fname,5) will return "Edwar", etc.

As for date function you can use GetDate function (don't forget to add dos uses).

PHP:
procedure GetDate(var Year, Month, Day, DayofWeek: Word);
Get user birthday, get today's date, calculate the difference and convert to days. Something like that, I'm sure you can figure this one out :D.
 
Joined
Sep 1, 2010
Messages
5,900 (2.22/day)
Likes
6,568
#5
A tiny hint:

In Pascal before the final end always use readln it will keep the working screen on
 
Joined
Sep 15, 2009
Messages
2,076 (0.69/day)
Likes
379
System Name Omen
Processor i7-4710HQ
Cooling Dual fan/heatpipe
Memory 16GB
Video Card(s) 4GB GTX 860M
Storage 256GB PCIE SSD/256GB PNY UHS-1 SD Card
Display(s) 15.6' 1080P
Case Aluminium
Audio Device(s) Onboard
Power Supply Brick
Software Win 10
#6
Thankyou! :)
 

Kreij

Senior Monkey Moderator
Staff member
Joined
Feb 6, 2007
Messages
13,817 (3.48/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
Processor Intel Core 2 Quad QX9650 Extreme @ 3.0 GHz
Motherboard Asus Rampage Formula
Cooling ZeroTherm Nirvana NV120 Premium
Memory 8GB (4 x 2GB) Corsair Dominator PC2-8500
Video Card(s) 2 x Sapphire Radeon HD6970
Storage 2 x Seagate Barracuda 320GB in RAID 0
Display(s) Dell 3007WFP 30" LCD (2560 x 1600)
Case Thermaltake Armor w/ 250mm Side Fan
Audio Device(s) SupremeFX 8ch Audio
Power Supply Thermaltake Toughpower 750W Modular
Software Win8 Pro x64 / Cat 12.10
#7
Moved to programming forum.
Memory lane ... I haven't written anything in Pascal since the '80's
 
Joined
Feb 8, 2005
Messages
1,675 (0.36/day)
Likes
149
Location
Minneapolis, Mn
System Name Livingston
Processor i7-4960HQ
Motherboard macbook prp retina
Cooling Alphacool NexXxoS Monsta (240mm x 120mm x 80mm)
Memory 16Gb
Video Card(s) Zotac Arctic Storm Nvidia 980ti
Display(s) 1x Acer XB270HU, 1x Catleap, 1x Oculus
Benchmark Scores http://www.3dmark.com/fs/770087
#8
I love all of you, and my pascal skills are limited to 3 assignments and lots of vodka. If you need help with Jquery/CSS/Html C# or .net let me know. :)

P.S. Kreij where are you? I grew up in Green Bay and still consider it my home. On contract (loan) in the cities though.
 

Kreij

Senior Monkey Moderator
Staff member
Joined
Feb 6, 2007
Messages
13,817 (3.48/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
Processor Intel Core 2 Quad QX9650 Extreme @ 3.0 GHz
Motherboard Asus Rampage Formula
Cooling ZeroTherm Nirvana NV120 Premium
Memory 8GB (4 x 2GB) Corsair Dominator PC2-8500
Video Card(s) 2 x Sapphire Radeon HD6970
Storage 2 x Seagate Barracuda 320GB in RAID 0
Display(s) Dell 3007WFP 30" LCD (2560 x 1600)
Case Thermaltake Armor w/ 250mm Side Fan
Audio Device(s) SupremeFX 8ch Audio
Power Supply Thermaltake Toughpower 750W Modular
Software Win8 Pro x64 / Cat 12.10
#9
P.S. Kreij where are you? I grew up in Green Bay and still consider it my home. On contract (loan) in the cities though.
I'm out in the sticks near Montello, WI (Marqette County).
I grew up in the Chicago area but have adopted WI as my real home.
I taught myself Pascal when working for GE. Wrote various utilities and a SQA bug tracking database in Pascal while working at the MRI division.
Feature creep caused it's demise and we converted it over to a 3rd party DBS system.

Anyway, Pascal is an easy language to work in, I'm just surprised they still teach it as most companies that I know of are going with straight "C" or an OOP/Net language for just about everything.
 
Joined
Feb 8, 2005
Messages
1,675 (0.36/day)
Likes
149
Location
Minneapolis, Mn
System Name Livingston
Processor i7-4960HQ
Motherboard macbook prp retina
Cooling Alphacool NexXxoS Monsta (240mm x 120mm x 80mm)
Memory 16Gb
Video Card(s) Zotac Arctic Storm Nvidia 980ti
Display(s) 1x Acer XB270HU, 1x Catleap, 1x Oculus
Benchmark Scores http://www.3dmark.com/fs/770087
#10
I'm out in the sticks near Montello, WI (Marqette County).
I grew up in the Chicago area but have adopted WI as my real home.
I taught myself Pascal when working for GE. Wrote various utilities and a SQA bug tracking database in Pascal while working at the MRI division.
Feature creep caused it's demise and we converted it over to a 3rd party DBS system.

Anyway, Pascal is an easy language to work in, I'm just surprised they still teach it as most companies that I know of are going with straight "C" or an OOP/Net language for just about everything.
Yeah its a mix of C# and .Net here.
 
Joined
Sep 3, 2010
Messages
3,443 (1.29/day)
Likes
1,685
Location
NL, Europe
Processor Intel Core i5-4460
Motherboard Gigabyte GA-Z97-D3H
Cooling Arctic Freezer i11
Memory Crucial Ballistix Sport, DDR3-1600, 2x4 GB kit
Video Card(s) Sapphire Radeon R9 270X Vapor-X
Storage Kingston SSDNow V300 (120GB) + Seagate Barracuda 7200.14 (1TB)
Display(s) AOC G2260VWQ6 | Acer AL1916 (in reserve)
Case Cooler Maste Centurion 5
Audio Device(s) integrated
Power Supply Seasonic G450
Mouse Logitech G500
Keyboard Qpad MK-50
Software Windows 10
#11
I'm out in the sticks near Montello, WI (Marqette County).
Anyway, Pascal is an easy language to work in, I'm just surprised they still teach it as most companies that I know of are going with straight "C" or an OOP/Net language for just about everything.
I remembered being taught some basics in Pascal too, after that Delphi. I guess it is to get familiar with programming in general and not really about learning the language itself that much.
 
Joined
Sep 7, 2010
Messages
752 (0.28/day)
Likes
152
Processor Intel Core i7-4790K
Motherboard Intel Board DZ87KLT-75K
Cooling Intel Stock Cooler
Memory G.Skill RipjawsX {F3-2400C11D-16GXM x 2 [32GB]}
Video Card(s) Nvidia Geforce GTX 970
Storage Samsung EVO 250GB mSATA SSD + Seagate 3TB HDD
Display(s) Dell UltraSharp U2718Q
Case In Win F430
Power Supply Seasonic Platinum 660
Mouse Dell KM714 Wireless
Keyboard Dell KM714 Wireless
Software Windows 10 Pro x64
#12
I remember our project was to automate a car hire service, was straight A+ material easy,.... but down memory lane cant remember much of it tho a slight polish and it will all come back. Damn I and a friend of mine finished our project that was to take a month and even had time to make a game (Was a board game X/O) though i did like only 1/4 of the code and 100% testing while he did 3/4 of rest of the game code was running in his head like damn. He recently buzzed me and said we should make/ design a new game, i Told him i think most of my code skills are gone its been like 10 years since i wrote any serious code, But Oh well the game project currently in research stage we are checking out several game engines, to see what can suit us best, if we could get our hands on FOX Engine,... would be nice.

@1nf3rn0x sorry i went off topic but this brings lots of memories..