國立暨南國際大學 97 學年度第一學期小考試卷

 
科目名稱:資訊系統 與網路導論 開課系所:資訊工程 學系 任課教師
吳坤熹
系所別:
年級:
學號:
姓名:
考試日期
2008.11.26

(考試時間: 14:10-14:20)

  1. (10%) What value will the following code display?

    #include <iostream>
    using std::cout;
    using std::endl;

    int main()
    { // Check the precedence table on P.77
    cout << 2 << 2 << 2 << endl;
    cout << (2 << 2 << 2) << endl;
    }





  2. (10%) Determine whether the following code is correct or not.  If it is correct, predict its output.  If it is incorrect, point out the mistake(s).
    #include <iostream>
    int main()
    {
    const int MAX = 50;
    int i = 1, sum = 0;
    for ( ; ++i <= MAX; sum += i)
    ;
    std::cout << std::endl << "sum = " << sum
    << std::endl << "i = " << i
    << std::endl;
    return 0;
    }