As we are using a pointer value to copy a string, So it will be producing a runtime error. Output: $ g++ res3.cpp $ a.out segmentation fault
Question 5.
What is the output of this program?
1. #include 2. using namespace std; 3. int funcstatic(int) 4. { 5. int sum = 0; 6. sum = sum + 10; 7. return sum; 8. } 9. int main(void) 10. { 11. int r = 5, s; 12. s = funcstatic(r); 13. cout
10
15
error
none of the mentioned
Explanation:-
Answer: Option A. -> 10
Eventhough we passed the value, we didn't caught to manipulate it, So it is printing as 10. Output: $ g++ res2.cpp $ a.out 10
Question 6.
What is the output of this program?
1. #include 2. using namespace std; 3. int main(void) 4. { 5. const char *one = "Test"; 6. cout
Test
TestTest
Te
none of the mentioned
Explanation:-
Answer: Option B. -> TestTest
We are copying the values from one variable to other, So it is printing is TestTest Output: $ g++ res1.cpp $ a.out TestTest
Question 7.
What can go wrong in resource management on c++?
Leakage
Exhaustion
Dangling
All of the mentioned
Explanation:-
Answer: Option D. -> All of the mentioned
If there is any mishap in memory or resource management means, the problems that are mentioned
above can happen.
Question 8.
When we call that resource is leaked?
Arise of compile time error
It cannot be accessed by any standard mean.
Arise of runtime error
none of the mentioned
Explanation:-
Answer: Option B. -> It cannot be accessed by any standard mean.
Resource is said to be leaked when it cannot by accessed by any means of standard mean.
Question 9.
What kind of error can arise when there is problem in memory?
Segmentation fault
Produce an error
Both a & b
none of the mentioned
Explanation:-
Answer: Option A. -> Segmentation fault
None
Question 10.
What is the output of this program?
1. #include 2. #include 3. using namespace std; 4. int main () 5. { 6. int i, n; 7. int * p; 8. i = 2; 9. p= new (nothrow) int[i]; 10. if (p == 0) 11. cout
5
55
555
Error: memory could not be allocated
Explanation:-
Answer: Option B. -> 55
As we had given i value as 2, It will print the 5 for two times. Output: $ g++ res.cpp $ a.out 55