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

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

(考試時間: 16:30-17:00)

  1. (10%) What value will the following code display?

    #include <iostream>
    int main() // Quiz 5-1: Understanding bitwise operators.
    {
    unsigned s = 318;

    int i = (s >> 4) & ~(~0 << 3);
    std::cout << i;
    }




  2. (10%) What will the following code display?
         #include <iostream>
    using std::cout;

    int main() {
    int n = 22;
    cout << ++n ;
    cout << n++ << "\n";
    }



  3. (10%) What will the following code display?

    #include <iostream>
    using std::cout;
    int main()
    {
        unsigned char a=0xA5;
        unsigned char b=static_cast<char>(~a)>>4;
        // cout <<b;
        printf("a=%d\n",a);
        printf("b=%d\n",b);

        return 0;
    }



  4. (10%) What will the following code display?

    #include <iostream>
    using std::cout;
    using std::endl;

    int main()
    {
       int x=2, y, z;
       x *= (y=z=5); cout << x << endl;
       z = 3;
       x == (y=z); cout << x << endl;
       x = (y==z); cout << x << endl;
       x = (y&z); cout << x << endl;
       x = (y&&z); cout << x << endl;
       y = 4;
       x = (y|z); cout << x << endl;
       x = (y||z); cout << x << endl;
       return 0;
    }