ICT
the blog for ICT
ken013194
暱稱: ホロ
性別: 男
國家: 香港
地區: 葵青區
« August 2026 »
SMTWTFS
1
2345678
9101112131415
16171819202122
23242526272829
3031
最新文章
Text File
Arrays
String Procedures
String Functions
String Operation
文章分類
全部 (23)
Programming Language (23)
訪客留言
最近三個月尚無任何留言
每月文章
日誌訂閱
尚未訂閱任何日誌
好友名單
尚無任何好友
網站連結
尚無任何連結
最近訪客
最近沒有訪客
日誌統計
文章總數: 23
留言總數: 0
今日人氣: 0
累積人氣: 102
站內搜尋
RSS 訂閱
RSS Feed
2009 年 9 月 11 日  星期五   晴天


Assignment Stat 分類: Programming Language

High-level Programming Language (Pascal)

Assignment Statements

  • gives a value or computational result to a variable
  • the syntax of an assignment statement is

    <variable> := <expression>

    • <expression> may be a constant value, another variable already holding a value or a formula to be evaluated
    • := is known as the assignment operator (means 'gets the value of ')
    • no space between a colon (:) and an equal sign (=)

  • the expression on the right hand side is evaluated first, then the result is stored in the variable on the left
  • once a variable is assigned a new value, the previous value, if any, will be replaced or overwritten by the new value
  • the expression must be assignment compatible (e.g. of the same data type) with the variable identifier
  • it is legal to assign an integer value to a real variable, the integer value will be converted to the corresponding real value
  • it is not legal to assign a real value to an integer variable
  • the following are examples of invalid Pascal assignment statements with reasons

    var Number : integer;
      Code : char;
      Found : boolean;

    Statement
    Error
    5 := Number; variable must appear on the left of the assignment operator
    Number+3.5 := 2.7; arithmetic expressions may not appear on the left of the assignment operator
    Code := 5; numeric value may not be assign to a character variable
    Number := '5'; character constant may not be assigned to a numeric variable
    Number := 3.4; real value may not be assigned to an integer variable
    Number :='2'+'3'; '2'+'3' is not a legal expression
    Found := 'false' 'false' is not a Boolean expression





訪客留言 (返回 ken013194 的日誌)

訪客名稱:
電郵地址: (不會公開)
驗證碼:  按此更新驗證碼 (如看不清楚驗證碼請點擊圖片刷新)
俏俏話: (必需 登入 後才能使用此功能)
[ 開啟多功能編輯器 ]