| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 718 人关注过本帖
标题:请高手帮忙做几道题^^谢谢
只看楼主 加入收藏
纸玻璃
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-1-25
收藏
 问题点数:0 回复次数:0 
请高手帮忙做几道题^^谢谢
Programming Fundamentals: Hwang Robert : F 1  
Time elapsed:   1:1    Be sure to check before submission. You can submit your test(quiz/exam) only one time.

 
   
      
    1. What is the output from of the following programs?



#include

using namespace std;

void fn();

int main()

{
int a = 7;

fn();

cout << a;

return 0;

}

void fn()

{ static int b = 8;

b++;

}

 
     
   
  2. What is the output from of the following programs?



#include

using namespace std;

void fn(int);

int main()

{ fn(8);

return 0;

}

void fn(int a)

{ cout << a + 1 << endl;

}

 
     
   
  3. What value does the following program return to the operating system?



#include

using namespace std;

int fn(int);

int main()

{ int x = fn(7);

return 0;

}

int fn(int a)

{ return a++;

}

 
     
   
  4. What is the exact output of the following program?



#include

#include

using namespace std;

int main()

{ int init[] = {2,4,6,8,10};

vector v(init, init+5);

cout << "The vector is: ";

for(int i=1;i
cout << v[i] << " ";

cout << endl;

return 0;

}

 
     
   
  5. The first two lines output by the following program are “4” and “0012FF6C”. What are the following lines?



#include

using namespace std;

int main()

{ int a[] = {2,4,6,8,10};

cout << sizeof(a[1]) << endl

<< &a[0] << endl

<< sizeof(a) << endl

<< a[3] << endl

<< &a[1] << endl

<< *(a+2) << endl

<< a << endl;

return 0;

}

 
     
   
  6. What are the main uses of a constructor function?



 
     
   
  7. What is the purpose of the statement “using namespace std;” in a program?  
     
   
  8. For the student marks case study (Appendix A), what would be the exact contents of the file “out.txt” if the current main function were replaced with this one?

int main()

{university cdut;

student* s

s = cdut.add_student(2468,"Ross");

s = cdut.add_student(1012,"Noel");



ofstream fout("out.txt");

cdut.print(fout);

s2->print(fout);

fout.close();



return 0;

}

 
     
   
  9. What is the output from of the following programs?


#include
using namespace std;
void fn(int*);
int main()
{
int a = 7;
fn(&a);
cout << a << endl;
return 0;
}
void fn(int *b)
{
(*b)++;
}
 
     
   
  10. What is the output from of the following programs?


#include
using namespace std;
int a;
void fn();
int main()
{
a = 7;
fn();
cout << a < endl;
return 0;
}
void fn()
{
a++;
}
搜索更多相关主题的帖子: Robert int output void 
2008-01-25 20:08
快速回复:请高手帮忙做几道题^^谢谢
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035845 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved