quinta-feira, 21 de março de 2013

Pascal Data Types, IDE and First program

Introduction to Programming - Module 1

3. Pascal's basic data types.


On this lesson, you'll learn some of the basic data types, if you already know, skip ahead.


Alphanumeric :

String (255 characters) ;
 Char(a single character)

Numeric:

Short int (-128...127);
 Integer(-32768....32767);
 Long int(-2147483648...2147483647);
Real(2,9*10E-39...1,7*10E38);

Boolean
(True or False)


There's also structured data types like arrays, records, sets, files, etc.. But don't worry about these until the previous ones are fully understood.

4. What IDE to use?

I Personally am using Dev-Pascal on windows 7.
You can download it from http://www.bloodshed.net/devpascal.html

Press Ctrl+U to open up a new source file.

To Compile your program click the green icon shown above.

If the program is successfully compiled you can hit Execute to run it, otherwise hit Continue and fix the errors.


5. Pascal program structure


This is how every Pascal program begins.

 And variables go there


The text inside the curly brackets is a comment, this is very useful in bigger projects, to keep things tidy.


6. First Programs

Finally, let's do some programming:









If you type that in, compile and run the code it will show a console box and automatically close.
To prevent this from happening type readln; this asks for input, only closing the program when input in recieved (you can just click enter).


So writeln outputs data, and readln recieves data. Let's see how to store the data recieved in a variable:























The program output is :




You can also declare multiple variables with different types. Example:



End of Module 1

I hope you enjoyed reading this as much as I did writting it, this is the end of Module 1, you are now able to code simple applications in Pascal. Module 2 is on it's way to be on the website, it is going to be much more exciting than this one! If you think this is good content go ahead and share the webpage with people who are also interested in Programming.

0 comentários

Posts a comment

 
© Doc's Workshop
Designed by Blog Thiết Kế
Back to top