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

科目名稱:計算機概論 開課系所:資訊工程 學系 考試日期 2012.11.20
系所別:
年級:
學號:
姓名:
考試時間 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).
    // Pass-by-value
    #include <iostream>
    using std::cout;
    using std::endl;

    int incr(int num)
    {
        return ++num;
    }

    int main()
    {
        int num = 11;
        cout << num << endl;
        cout << incr(num) << endl;
        cout << num << 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).
    // Function prototype
    #include <iostream>
    using std::cout;
    using std::endl;

    void print_stars(int n);        // Function prototype

    int main()
    {
        int i;
        const int MAX = 5;
        for (i=1; i<=2*MAX-1; i++)
        {
            print_stars( i<=MAX ? i : 2*MAX-i);
        }
        return 0;
    }

    void print_stars(int n) // Function to print n stars
    {
         int j;
         for (j=0; j<n; j++)
             cout << '*';
         cout << endl;
         return;
    }



  3. (10%) 請默寫楊峻權主任有關資訊與創意的十六字真言(今天有帶領大家呼口號)。