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

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

    int main()
    {
        int a = 3;
        int b = 0;   
        b = a++ * 3;
        std::cout << a << ' ' << b << std::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).
    #include <iostream>

    int main()
    {
        int a = 3;
        int b = 0;    
        b = ++a * 3;
        std::cout << a << ' ' << b << std::endl;
        return 0;
    }

  3. (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()
    {
        int i;
        for (i=1; i<8; i++)
        {
            if (i>2)
            {
                if (i==3) continue;
                if (i==5) break;
            }
            std::cout << i << std::endl;
        }
        return 0;
    }