國立暨南國際大學 100 學年度第一學期小考試卷
(考試時間: 14:10-14:25)
科目名稱:資訊系統
與網路導論 |
開課系所:資訊工程
學系 |
任課教師
|
吳坤熹
|
系所別:
|
年級:
|
學號:
|
姓名:
|
考試日期
|
2011.11.9
|
-
(10%) What will the following code display?
// character arrays
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int main()
{
char greek[5][8] = { "Alpha", "Beta", "Gamma", "Delta", "Epsilon" };
// cout << greek << endl; // This will print the starting address of the array
cout << greek[0] << endl;
cout << greek[0][0] << endl;
return 0;
}
- (10%)
Determine whether the following code has syntax errors or not. If
it is correct, predict its output. If it is incorrect, point out
the mistake(s).
// size of character arrays
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int main()
{
char greek[5][8] = { "Alpha", "Beta", "Gamma", "Delta", "Epsilon" };
cout << sizeof greek << endl;
cout << sizeof greek[0] << endl;
cout << sizeof greek[0][0] << endl;
return 0;
}
- (10%)
Determine whether the following code has syntax errors or not. If
it is correct, predict its output. If it is incorrect, point out
the mistake(s).
// pointer to char
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int main()
{
char greek[5][8] = { "Alpha", "Beta", "Gamma", "Delta", "Epsilon" };
char* pstr = greek[2];
cout << pstr << endl;
return 0;
}