
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question

Transcribed Image Text:4. What is the output of the following program:
void fun (int n) {
}
cout << n;
if (n = 3)
return;
fun (n+1);
cout << n;
a. 12
b. 132
c. 12321
d. 1234
vector <int> v2 = {3};
v2 = v1;
e. 12345
5. Consider the following code segment, and select the best answer:
vector <int> vl =
(11, 23, 99};
for (int i = 0; i < 3; i++)
cout << v2.at (i) << " ";
The output will be:
a. 11 23 99
b. 3 23 99
int main()
{
}
a. This code gives a compilation error on the second line.
b. This code prints 6.
c. This code prints -6.
d. None of the above
fun (1);
return 0;
c. 3
d. There will be no output due to improper assignment operation in the
third line.
6. Consider the following code segment. Which one of the following statements is true?
string s1 = "893";
s1 += "99";
int y = s1.at (2) sl.at (4);
cout << y;
![15. In a C or C++ program, header files normally do NOT contain:
a. include directives
b. constants
C. struct definitions
d. function prototypes
e. function definition/implementation
16. Consider the following code segment that dynamically allocates memory on the heap to create and use it as a
matrix with 4 rows, and 3 columns:
int **a = new int* [4];
for (int i = 0; i <4; i++) {
}
Which one of the following statements is the proper way to de-allocate/remove the allocated memory from heap:
for (int i= 0; i < 3; i++)
delete [ a[i];
a
b
с
a[i] = new int [3];
for (int j=0; j < 3; j++)
a[i] [j] = 0;
delete [] a;
delete [] a;
for (int i = 0; i < 4; i++)
delete [] a [i];
for (int i = 0; i < 4; i++)
delete [] a[i];
delete [] a;
d delete [] a;
};
Consider the following definition of class Box and main function. Assuming constructor, copy constructor,
assignment operator, and destructor of this class are properly without any error implemented, answer the
following four questions:
class Box {
public:
Box();
~Box ();
Box (const Box & source);
Box& operator= (const Box & rhs);
private:
int* pointer;
int main (void) {
Box x;
Box y (x);
Box *z = new Box;
x = y;
return 0;
17. How many times the constructor of class Box is called?
Once
a.
b. Twice
c. Three times
d. None of the above
18. How many times the copy-constructor of class Box is called?
a. Once
b. Twice
c. Three times
d. None of the above
20. How many times destructor of class Box is called
}
a. Once
b. Twice
c. Three times
d. None of the above
19. How many times assignment operator of class Box is called
a. Once
b. Twice
c. Three times
d. None of the above
m reaches point 1, for the second](https://content.bartleby.com/qna-images/question/94884f69-365e-43dc-a457-f3f8066ccdfc/252eed10-416b-4cab-b7c5-c160681751ba/n2bvej5_thumbnail.png)
Transcribed Image Text:15. In a C or C++ program, header files normally do NOT contain:
a. include directives
b. constants
C. struct definitions
d. function prototypes
e. function definition/implementation
16. Consider the following code segment that dynamically allocates memory on the heap to create and use it as a
matrix with 4 rows, and 3 columns:
int **a = new int* [4];
for (int i = 0; i <4; i++) {
}
Which one of the following statements is the proper way to de-allocate/remove the allocated memory from heap:
for (int i= 0; i < 3; i++)
delete [ a[i];
a
b
с
a[i] = new int [3];
for (int j=0; j < 3; j++)
a[i] [j] = 0;
delete [] a;
delete [] a;
for (int i = 0; i < 4; i++)
delete [] a [i];
for (int i = 0; i < 4; i++)
delete [] a[i];
delete [] a;
d delete [] a;
};
Consider the following definition of class Box and main function. Assuming constructor, copy constructor,
assignment operator, and destructor of this class are properly without any error implemented, answer the
following four questions:
class Box {
public:
Box();
~Box ();
Box (const Box & source);
Box& operator= (const Box & rhs);
private:
int* pointer;
int main (void) {
Box x;
Box y (x);
Box *z = new Box;
x = y;
return 0;
17. How many times the constructor of class Box is called?
Once
a.
b. Twice
c. Three times
d. None of the above
18. How many times the copy-constructor of class Box is called?
a. Once
b. Twice
c. Three times
d. None of the above
20. How many times destructor of class Box is called
}
a. Once
b. Twice
c. Three times
d. None of the above
19. How many times assignment operator of class Box is called
a. Once
b. Twice
c. Three times
d. None of the above
m reaches point 1, for the second
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 3 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- #include using namespace std; Type the program's output int main() { int g; g = 3; while (g <= 5) { } cout << g << endl; g = g + 1; return 0;arrow_forwardInstructions: Kindly provide comments that explains the program code below. (NOTE: this is a C program language) #include <stdio.h> int fact_recur(int n){if(n==0) return(1);return(n*fact_recur(n-1));} int fact_for(int n){ int fact=1; for(int i=1;i<=n;i++){ fact=fact*i; return fact; } }int main(void) { int number; printf("input number is: "); scanf("%d",&number); printf("factorial using for loop: %d",fact_recur(number)); printf("\nfactorial using recursion: %d",fact_recur(number)); return 0;}arrow_forwardQ1: 1. What is the output of this C code? void main(){ int a = 0, i = 0, b; for (i=0;i< 5; i++){ a++;continue; } cout<<"i="<arrow_forward4. What is the output of the following program: void fun (int n) { } cout << n; if (n = 3) return; fun (n+1); cout << n; a. 12 b. 132 c. 12321 d. 1234 e. 12345 int main () Bo{ } fun (1); return 0;arrow_forwardê #include using namespace std; int main() { int count = 5; int num = 2; while (count r && num ){ cout << count << " " << num << endl; count -=1; if (count % 2 == 0) num -=1; } return 0; Output: 52 4 1 3 1 20 10arrow_forward#include using namespace std; Type the program's output int main() { int g; g = 0; while (g >= −2) { } cout << g << endl; g = g - 1; return 0;arrow_forwardarrow_back_iosarrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education