techPowerUp! Forums

Go Back   techPowerUp! Forums > Software > Programming & Webmastering

Reply
 
Thread Tools
Old May 29, 2012, 06:31 AM   #1
1nf3rn0x
1000 Posts
 
1nf3rn0x's Avatar
 
Join Date: Sep 2009
Location: Sydney, Australia
Posts: 1,707 (1.27/day)
Thanks: 509
Thanked 331 Times in 242 Posts

System Specs

Basic Pascal

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.

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!
__________________
1nf3rn0x is offline  
Reply With Quote
Old May 29, 2012, 06:51 AM   #2
Vinska
200 Posts
 
Vinska's Avatar
 
Join Date: Jul 2011
Location: Kaunas, Lithuania
Posts: 457 (0.68/day)
Thanks: 292
Thanked 196 Times in 120 Posts
Send a message via Skype™ to Vinska

System Specs

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 ;]
__________________
Why do you wear glasses if you're deaf?
Code:
while (1) {
	alone();
}
Vinska is offline  
Crunching for Team TPU
Reply With Quote
The Following User Says Thank You to Vinska For This Useful Post:
Old May 29, 2012, 06:57 AM   #3
1nf3rn0x
1000 Posts
 
1nf3rn0x's Avatar
 
Join Date: Sep 2009
Location: Sydney, Australia
Posts: 1,707 (1.27/day)
Thanks: 509
Thanked 331 Times in 242 Posts

System Specs

Quote:
Originally Posted by Vinska View Post
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.
__________________
1nf3rn0x is offline  
Reply With Quote
Old May 29, 2012, 07:21 AM   #4
okidna
200 Posts
 
okidna's Avatar
 
Join Date: Jan 2012
Location: Indonesia
Posts: 362 (0.71/day)
Thanks: 496
Thanked 271 Times in 151 Posts

System Specs

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 Code:
uses crt;

var
fnamesname 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 Code:
procedure GetDate(var YearMonthDayDayofWeekWord); 
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 .
okidna is offline  
Crunching for Team TPU
Reply With Quote
The Following User Says Thank You to okidna For This Useful Post:
Old May 29, 2012, 09:10 AM   #5
Drone
1000 Posts
 
Drone's Avatar
 
Join Date: Sep 2010
Location: Nonlocal location
Posts: 1,897 (1.91/day)
Thanks: 62
Thanked 822 Times in 525 Posts

System Specs

A tiny hint:

In Pascal before the final end always use readln it will keep the working screen on
__________________
...the young Universe was filled with a hot dense soup of interacting protons, electrons and photons at about 2700șC. When the protons and electrons joined to form hydrogen atoms, the light was set free
Drone is offline  
Reply With Quote
The Following User Says Thank You to Drone For This Useful Post:
Old May 29, 2012, 10:42 AM   #6
1nf3rn0x
1000 Posts
 
1nf3rn0x's Avatar
 
Join Date: Sep 2009
Location: Sydney, Australia
Posts: 1,707 (1.27/day)
Thanks: 509
Thanked 331 Times in 242 Posts

System Specs

Thankyou!
__________________
1nf3rn0x is offline  
Reply With Quote
Old May 29, 2012, 10:53 AM   #7
Kreij
Hardcore Monkey Moderator
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,114 (5.27/day)
Thanks: 591
Thanked 5,492 Times in 2,936 Posts

System Specs

Moved to programming forum.
Memory lane ... I haven't written anything in Pascal since the '80's
__________________

Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other.


Get more tech news on a wide variety of topics at NextPowerUp
Kreij is offline  
Reply With Quote
Old May 31, 2012, 06:12 AM   #8
GSG-9
1000 Posts
 
GSG-9's Avatar
 
Join Date: Feb 2005
Location: Minneapolis, Mn
Posts: 1,425 (0.47/day)
Thanks: 127
Thanked 142 Times in 125 Posts
Send a message via AIM to GSG-9 Send a message via Skype™ to GSG-9

System Specs

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.
GSG-9 is offline  
Reply With Quote
Old May 31, 2012, 12:40 PM   #9
Kreij
Hardcore Monkey Moderator
 
Kreij's Avatar
 
Join Date: Feb 2007
Location: Cheeseland (Wisconsin, USA)
Posts: 12,114 (5.27/day)
Thanks: 591
Thanked 5,492 Times in 2,936 Posts

System Specs

Quote:
Originally Posted by GSG-9 View Post
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.
__________________

Cloud (noun, singular): A dynamic arrangement of multiple potential single points of failure, with a user at one end and their data at the other.


Get more tech news on a wide variety of topics at NextPowerUp
Kreij is offline  
Reply With Quote
Old May 31, 2012, 01:06 PM   #10
GSG-9
1000 Posts
 
GSG-9's Avatar
 
Join Date: Feb 2005
Location: Minneapolis, Mn
Posts: 1,425 (0.47/day)
Thanks: 127
Thanked 142 Times in 125 Posts
Send a message via AIM to GSG-9 Send a message via Skype™ to GSG-9

System Specs

Quote:
Originally Posted by Kreij View Post
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.
GSG-9 is offline  
Reply With Quote
Old May 31, 2012, 01:41 PM   #11
Chevalr1c
2000 Posts
 
Chevalr1c's Avatar
 
Join Date: Sep 2010
Location: Tilburg, Netherlands
Posts: 2,058 (2.07/day)
Thanks: 4,952
Thanked 785 Times in 531 Posts

System Specs

Quote:
Originally Posted by Kreij View Post
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.
Chevalr1c is offline  
Crunching for Team TPU
Reply With Quote
Old May 31, 2012, 02:09 PM   #12
Protagonist
500 Posts
 
Protagonist's Avatar
 
Join Date: Sep 2010
Posts: 674 (0.68/day)
Thanks: 18
Thanked 112 Times in 86 Posts

System Specs

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..
Protagonist is offline  
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic networking HUSKIE Networking & Security 10 Feb 4, 2011 08:17 AM
Visual Basic shuggans Programming & Webmastering 4 Dec 10, 2010 10:35 PM
basic directions? Firedawg ATITool 0 Feb 23, 2007 02:00 PM
Dynamic Disks vs Basic Disks/Basic Disks vs Dynamic Disks (differences etc.) Alec§taar General Software 0 Nov 28, 2006 01:55 PM
[Case Gallery] Basic Gamer vivanco Case Mod Gallery 15 Nov 3, 2006 03:14 AM


All times are GMT. The time now is 11:08 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
no new posts