请高手帮忙做几道题^^谢谢
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++;
}