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

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

Open book; turn off computer & mobile phone                    (考試時間: 16:30-16:45)

  1. (10%) Determine whether the following code has syntax erros or not.  If it is correct, predict its output.  If it is incorrect, point out the mistake(s).
    #include <iostream>
    using std::cout;
    using std::endl;

    long product(long a, long b)
    { return a*b; }

    long sum(long a, long b)
    { return a+b; }

    int main(void)
    {
    long (*pdo_it) (long, long);

    pdo_it = product;
    cout << pdo_it(3,5) << endl;
    pdo_it = sum;
    cout << pdo_it(product(5,pdo_it(4,3)),6) << endl;
    return 0;
    }
  2. (10%) Determine
    whether the following code has syntax erros or not.  If it is correct,
    predict its output.  If it is incorrect, point out the mistake(s).
    #include <iostream>
    using std::cout;

    int sum(int arg1 = 10, int arg2 = 20, int arg3 = 30, int arg4 = 40);

    int main()
    {
    cout << sum(5, 5) << "\n";
    return 0;
    }

    int sum(int arg1, int arg2, int arg3, int arg4)
    {
    return arg1 + arg2 + arg3 + arg4;
    }