A variable declared before and outside all function

  

1. Question : (TCO 4) A variable declared before and outside all function blocks
is visible only in main.
is visible to all functions.
is visible to all functions except main.
is not visible to any functions.
2. Question : (TCO 4) What is the value of i after the following code fragment executes?
int i = 2;
int k = 5 ;
i *= k + 1;
7
11
12
14
3. Question : (TCO 4) How many times will variable i be printed to the screen?
for (i = 1 ; i <= 20 ; i = i + 2);
{
cout << “ “ << i ;
}
10
20
1
0
4. Question : (TCO 4) Which looping statement is best if the number of iterations is known?
If/Else
For
While
Do/While
5. Question : (TCO 4) C++ selection statements include
for, while, do-while.
cout and cin.
if, if-else, if-else if, switch.
#include and using namespace std;.
6. Question : (TCO 4) If firstName and lastName are string object variables, which statement can be used to combine (append or concatenate) the two into a single string variable?
fullName = firstName + lastName;
fullName = firstName, lastName;
fullName = firstName & lastName;
fullName = firstName && lastName;
7. Question : (TCO 4) Which type of error does the following code fragment cause?
int main (void)
{
int MAX;
cout << “Enter array size: “ <> MAX;
int foo [MAX];
for (int i = 0; i <= MAX; i++)
{
foo = i * 2;
}
Compiler: Array size must be known at compile time.
Compiler: Variable MAX cannot be all uppercase.
Compiler: Array subscript out of bounds.
Run-time: User cannot enter a value for MAX.
8. Question : (TCO 4) The code below computes the length of a C-style string. What should the value of FLAG be?
char name[20]= “Lancilot”;
int length=0;
while(name[length] != FLAG)
{
length = length+1;
}
cout << length << endl;
‘’
20
NULL
0
9. Question : (TCO 4) Which type of error does the following code fragment cause?
const int MAX = 500;
int main (void)
{
int foo [MAX];
for (int i = 0; i <= MAX; i++)
{
foo = i * 2;
}
Compiler, because of out-of-bounds array subscript
Run-time, because of out-of-bounds array subscript
Compiler, because of invalid array initialization
None of the above. It does not create any type of error.
10. Question : (TCO 4) What is the declaration for a C-style string that can hold a name with up to 3 printable characters (for example, “Ron”)?
int name [3];
char name [3]
int name [4];
char name [4];
11. Question : (TCO 4) What is the output of the following code?
void func(int x)
{
x = x * 2;
}
int main( )
{
int x = 10;
func(x);
cout << x << endl;
}
20
30
10
5
12. Question : (TCO 4) Which of the following function definitions uses pass-by-values?
int myFunc( int * x, int * y );
int myFunc( int x, int y ) ;
int myFunc( int & x, int & y ) ;
int myFunc( int @ value1, int @ value2 ) ;
13. Question : (TCO 4) Which of the following statements call the following function correctly?
int MultiplyValues (int, int);
int a = MultiplyValues (int x, int y);
int a = MultiplyValues (10, 20);
double d = MultiplyValues (int 10, int 20);
All of the above
14. Question : (TCO 4) What is the output of the following code?
void func(int *x)
{
*x = *x * 3;
};
int main()
{
int x = 10;
func (&x) ;
cout << x << endl ;
}
20
30
10
5
15. Question : (TCO 4) A Distance class has two private members, ‘feet’, of type int, and ‘inches’, of type double. Which prototype correctly declares the copy constructor for such class?
Distance Distance(const Distance &);
Distance(const Distance &);
int Distance(int, double);
Distance(feet, inches);
16. Question : (TCO 4) The word const inside the parentheses of the following declaration of isEqual
bool isEqual (const Distance & rightSideObject) const;
ensures the member variables of the called objects are protected (cannot be changed).
ensures the argument passed in to the function is protected (cannot be changed).
ensures the return value of the function is protected (cannot be changed).
ensures the return value is routed to the proper variable.
17. Question : (TCO 4) Given the following class definition and lines of code, Line 1 in main is a call to what?
class Distance
{
private:
int feet;
double inches;
public:
Distance( );
Distance(int initFt, double initIn);
void setFeet(int feetIn);
void setInches(double inchesIn);
int getFeet() const;
double getInches( ) const;
};
int main( )
{
Distance d1; //Line 1
const int MAX = 100; //Line 2
Distance list[MAX]; //Line 3
Distance d2(1, 2.3); //Line 4
Distance * pDist; //Line 5
d1.feet = 5; //Line 6
// etc. – assume the remaining code is correct
}
The 0-argument Distance constructor
The 2-argument, int, double, Distance constructor
The 2-argument, double, int, Distance constructor
The 1-argument, int, Distance constructor
18. Question : (TCO 4) Creating one class from another in a parent/child hierarchy is an example of
encapsulation.
polymorphism.
inheritance.
abstraction.
19. Question : (TCO 4) Which of the following is a valid declaration to overload the following function?
int whatever (double x);
double whatever (double x);
int whatever (int x);
int whatever2 (double x);
int overload (double x);
20. Question : (TCO 4) How many parameters are required to overload the pre-increment operator for a class as a member function?
None
1
2
No limit
21. Question : (TCO 4) Given the following definitions and statements,
void myFunction (double * dptr);;
double data [10];
which of the following statements correctly calls the function passing in the address of the data array?
myFunction(data);
myFunction(&data);
myFunction(*data);
myFunction(data[0]);
22. Question : (TCO 4) Assume you have to write a class that makes use of dynamic memory allocation (the class needs to allocate and de-allocate memory). According to best practices, where would the keyword ‘delete’ be placed?
Classes are smart data types. The compiler takes care of calling new/delete
It is in the constructor.
It is in the destructor.
It is in a separate, dedicated function.
23. Question : (TCO 4) When writing a class, the compiler automatically creates some support functions for the class. What are some of these functions?
Assignment operator function
Copy constructor
Assignment operator and copy constructor
None of the above
24. Question : (TCO 4) Assume you have to write a class that makes use of dynamic memory allocation (the class needs to allocate and de-allocate memory). According to best practices, where would the keyword ‘new’ be placed?
Classes are smart data types. The compiler takes care of calling new/delete.
In the constructor
In the destructor
In a separate, dedicated function
25. Question : (TCO 4) What is wrong with the following C++ statements?
int * iptr;
double d = 123.321;
iptr = &d;
cout << *iptr;
The cout statement does not contain an endl.
The space following the ampersand should not be there.
The iptr variable cannot be given an address of a double.
All of the above

 

Calculate your paper price
Pages (550 words)
Approximate price: -

Why Choose Us

Quality Papers

We value our clients. For this reason, we ensure that each paper is written carefully as per the instructions provided by the client. Our editing team also checks all the papers to ensure that they have been completed as per the expectations.

Professional Academic Writers

Over the years, our Acme Homework has managed to secure the most qualified, reliable and experienced team of writers. The company has also ensured continued training and development of the team members to ensure that it keep up with the rising Academic Trends.

Affordable Prices

Our prices are fairly priced in such a way that ensures affordability. Additionally, you can get a free price quotation by clicking on the "Place Order" button.

On-Time delivery

We pay strict attention on deadlines. For this reason, we ensure that all papers are submitted earlier, even before the deadline indicated by the customer. For this reason, the client can go through the work and review everything.

100% Originality

At Essay USA, all papers are plagiarism-free as they are written from scratch. We have taken strict measures to ensure that there is no similarity on all papers and that citations are included as per the standards set.

Customer Support 24/7

Our support team is readily available to provide any guidance/help on our platform at any time of the day/night. Feel free to contact us via the Chat window or support email: support@acmehomework.com.

Try it now!

Calculate the price of your order

We'll send you the first draft for approval by at
Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

Essay USA has stood as the world’s leading custom essay writing services providers. Once you enter all the details in the order form under the place order button, the rest is up to us.

Essays

Essay Writing Services

At Essay USA, we prioritize on all aspects that bring about a good grade such as impeccable grammar, proper structure, zero-plagiarism and conformance to guidelines. Our experienced team of writers will help you completed your essays and other assignments.

Admissions

Admission and Business Papers

Be assured that you’ll definitely get accepted to the Master’s level program at any university once you enter all the details in the order form. We won’t leave you here; we will also help you secure a good position in your aspired workplace by creating an outstanding resume or portfolio once you place an order.

Editing

Editing and Proofreading

Our skilled editing and writing team will help you restructure you paper, paraphrase, correct grammar and replace plagiarized sections on your paper just on time. The service is geared toward eliminating any mistakes and rather enhancing better quality.

Coursework

Technical papers

We have writers in almost all fields including the most technical fields. You don’t have to worry about the complexity of your paper. Simply enter as much details as possible in the place order section.