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

科目名稱:計算機概論 開課系所:資訊工程 學系 考試日期 2012.11.6
系所別:
年級:
學號:
姓名:
考試時間 14:10-14:20
  1. (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).
    // pointer to int
    #include <iostream>

    using std::cout;
    using std::endl;

    int main()
    {
        int number1 = 11;
        int number2 = 22;
        int* pnumber = &number1;
        cout << (*pnumber)++ << endl;   // What would happen if you omit the parentheses?
        cout << number1 << number2 << endl;
        return 0;
    }


  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).
    // pointer to int
    #include <iostream>

    using std::cout;
    using std::endl;

    int main()
    {
        int number1 = 11;
        int number2 = 22;
        int* pnumber = &number2;
        cout << --*pnumber << endl;   // Is this a valid expression?
        cout << number1 << number2 << endl;
        return 0;
    }