1.2 Variables and Arithmetic Expressions

  • warning: Declaration of views_handler_argument::init(&$view, &$options) should be compatible with views_handler::init(&$view, $options) in /home/xnvgu7/public_html/sites/all/modules/views/handlers/views_handler_argument.inc on line 745.
  • warning: Declaration of views_handler_filter::options_validate(&$form, &$form_state) should be compatible with views_handler::options_validate($form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/handlers/views_handler_filter.inc on line 585.
  • warning: Declaration of views_handler_filter::options_submit(&$form, &$form_state) should be compatible with views_handler::options_submit($form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/handlers/views_handler_filter.inc on line 585.
  • warning: Declaration of views_handler_filter_boolean_operator::value_validate(&$form, &$form_state) should be compatible with views_handler_filter::value_validate($form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/handlers/views_handler_filter_boolean_operator.inc on line 149.
  • warning: Declaration of views_plugin_style_default::options(&$options) should be compatible with views_object::options() in /home/xnvgu7/public_html/sites/all/modules/views/plugins/views_plugin_style_default.inc on line 25.
  • warning: Declaration of views_plugin_row::options_validate($form, &$form_state) should be compatible with views_plugin::options_validate(&$form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/plugins/views_plugin_row.inc on line 135.
  • warning: Declaration of views_plugin_row::options_submit($form, &$form_state) should be compatible with views_plugin::options_submit(&$form, &$form_state) in /home/xnvgu7/public_html/sites/all/modules/views/plugins/views_plugin_row.inc on line 135.

本節以列印出華氏Farenheit-攝氏Celsius對照表來說明「變數」Variables及「算數式」Arithmetic Expressions。以程式來解說,共有四個程式。

先來看看第一個程式執行的結果:

將上結果分兩部份看,

一是每一列有兩個數字從0 -17到300 148,左邊的數字是華氏度數,右邊的數字是攝氏度數,華氏從0度開始,隔20度計算一次攝氏度數,直到300度為止。

第二部份自「argc = 4」開始,這是顯示argc、argv兩變數,詳見程式內說明。

本程式在課本The C Programming Language第9頁,請點此處下載程式後,閱讀程式片段及執行。

做完上述練習後,請至課本The C Programming Language第12頁,並請點此處下載程式後,閱讀程式片段及執行。

做完上述練習後,請至課本The C Programming Language第13頁,並請點此處下載程式後,閱讀Exercise 1-3及執行。

做完上述練習後,請至課本The C Programming Language第13頁,並請點此處下載程式後,閱讀Exercise 1-4及執行。

練習完上述四個程式,希望對「變數」Variables及「算數式」Arithmetic Expressions有初步的了解,萬一仍不清楚,沒關係,多執行程式,做中學。