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

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

Open book; turn off computer & mobile phone                    (考試時間: 10:30-10: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;

    int main()
    {
        int i = 0, sum = 0;
        const int max = 5;

        i = 1;
    KevinLabel:
        sum +=i;
        if (++i <= max)
            goto KevinLabel;

        cout << "sum=" << sum << endl
            << "i = " << i << 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;
    using std::endl;

    int main()
    {
        const N = 5;
            for (i=N; i>=1; i--)
        {
            for (j=1; j<=i; j++)
                cout << '*';
            cout << endl;
        }
        return 0;
    }


  3. (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;

    int main()
    {
        int i = 5;
        do
        {
            if (i==8) continue;
            cout << i << endl;
        } while (++i < 10);
        return 0;
    }