⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pasl1003.html

📁 This is programing tutorial for people who wants to know programing in PASCAL.Pascal might be not th
💻 HTML
字号:
<HTML><HEAD><TITLE>Pascal Tutorial - Chapter 4</Title>
<LINK href="../style.css" rel="stylesheet" type="text/css">
</head>
<body background="../tile01.jpg" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#FF0000">
<H1><center>Constants !</center></h1>

<P>Hello ! We meet again ! Get ready for this short one !
In  real  world,  we meet many constants, such as pi =  3.1415926513...  or
e  = 2.7182818284529... Many of these are impractical number so that it  is
quite  hard for us to remember, at least for some of us. Pascal has a  good
facility to use the constants. Even it has predefined ones, like <tt>pi</tt>.</p>
<p>
How to define our own constant ? Easy, just like a variable definition,  we
just give <tt>const</tt> above our constants AND start tayloring our needs.</p>
<pre>
const
  :
  myconst = 1234;
  :
  :
  (Like variable definition)
</pre><p>
We  just omit the constant type, Pascal will understand it. We can  use  it
just like a normal variable. Example :</p><hr><pre>
const
  myconst = 1234;
var
  i : word;
begin
  i:=40;
  writeln(i*myconst);
end.
</pre><hr><p>
Easy, no ? But heed my word, constants is unchangeable. If you try to change it,
Pascal will say error. Wait a minute ! I heard that Pascal's constants can be changed somewhere in
the program. You are absolutely right ! Now, the declaration becomes :
</p><pre>
const
  myconst : mytype = thevalue;
</pre><p>
example:</p><pre>
const
  abc : word = 1234;
</pre><p>
You may not declare constants with values exceeding the type, like these :</p><pre>
const
  aaa : word = 100000;  { Illegal because word is integer ranging 0-65535 }
  bbb : byte = 123.44;  { Illegal because of the fractional part }
  ccc : string = 123;   { Illegal because incompatible type }
</pre><p>
Clear ? How can we modify them inside our program ?</p><hr><pre>
const
  myconst : word = 1234;
var
  i : word;
begin
  i:=40; myconst:=1000;
  writeln(i*myconst);
end.
</pre><hr><p>
Easy, just like a normal variable, doesn't it ? That's all for this chapter !
</p><hr>
<p><B><H3>Where to go ?</H3></B>
<A HREF="../news.html">Back to main page</A><BR>
<A HREF="pasles01.html">Back to Pascal Tutorial Lesson 1 contents</A><BR>
<A HREF="pasq1003.html">To the quiz</A><BR>
<A HREF="pasl1002.html">Back to Chapter 3</A> about branching(<tt>if, case..of</tt>)<BR>
<A HREF="pasl1004.html">To Chapter 5</A> about looping in Pascal(<tt>for, while..do, repeat..until</tt>)<BR>
<A HREF="../mylink.html">My page of programming link</A><BR>
<A HREF="../faq.html">Contact me here</A>
<hr><P class="cpy">By : Roby Joehanes, &copy; December 1996</P>
</BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -