國立暨南國際大學 103 學年度第二學期小考試卷

科目名稱:程式設計 開課系所:資訊工程 學系 考試日期 2015.3.11
系所別:
年級:
學號:
姓名:
考試時間 10:30-10:40
  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).
    // MATH Functions
    #include <iostream>
    #include <cmath>
    using std::cout;
    using std::endl;

    int main()
    {
        cout << pow( 729.0, 1.0/6.0 ) << endl;
        cout <<  ceil( -3.5) << endl;
        cout << floor( -3.5) << 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).
    // MATH Functions
    #include <iostream>
    #include <cmath>
    using std::cout;
    using std::endl;

    int main()
    {
        int n = -3.5;
        int m = abs(-3.5);
        float a = fabs(-3.5);
        cout << n << endl;
        cout << m << endl;
        cout << a << endl;
        return 0;
    }