Question

51. What is the output of the following code snippet? int number = 0; int ptr_num -&number ptr_num 60; number-80 cout < ptr
0 0
Add a comment Improve this question Transcribed image text
Answer #1

51. Output will be 80 because ptr_num will be holding the address of variable "number" and since the latest value of "number" is 80, hence 80 will be printed. Option c is correct.

52. Since pointer "ptr" is pointing to variable "num" and in the statement "*ptr = *ptr+15" , the value of location pointed by ptr which is value of variable "num" will be incremented by 15. Hence the value of "num" will become 30 which is same as *ptr.

Hence the output will be 30 30. So option d is correct.

53. This will generate compilation error because input to the function "atoi() " which converts string to integer should have input of type "const char *" however the the input is not constant character pointer in atoi() function and hence compilation error will be generated.

Hence option c is correct.

Please comment for any clarification.

Add a comment
Know the answer?
Add Answer to:
51. What is the output of the following code snippet? int number = 0; int ptr_num...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • QUESTION 1 What is the output of the following code snippet? int main() { bool attendance...

    QUESTION 1 What is the output of the following code snippet? int main() { bool attendance = false; string str = "Unknown"; attendance = !(attendance); if (!attendance) { str = "False"; } if (attendance) { attendance = false; } if (attendance) { str = "True"; } else { str = "Maybe"; } cout << str << endl; return 0; } False True Unknown Maybe QUESTION 2 What is the output of the following code snippet? #include <iostream> #include <string> using...

  • What is the output of the following code snippet? (If there is some kind of syntax...

    What is the output of the following code snippet? (If there is some kind of syntax error indicate this by marking "error" in your answer choice) 1.        int fly = 5; int x;        if (fly-- > 5)               x = 5;        else               x = 2;        if (x++ > 3)               cout << x;        cout << fly << endl; 2.   int i = 0;        bool b = i == 0 || i++ > 0;        if (!b)               cout << i << endl;        else               cout...

  • What is the output? (3 pts) int num = 5; int* ptr = &num; cout <<...

    What is the output? (3 pts) int num = 5; int* ptr = &num; cout << ptr << endl; cout << &ptr << endl; cout << *ptr << endl;

  • Explain what each line of the following snippet of code does: int *ptr; ptr = new...

    Explain what each line of the following snippet of code does: int *ptr; ptr = new int; *ptr = 10; cout << ptr << ' ' << &ptr << ' ' << *ptr; delete ptr; cout << ptr << ' ' << &ptr << ' ' << *ptr;

  • Consider the following C++code snippet and what is the output of this program? # include<iostream> using...

    Consider the following C++code snippet and what is the output of this program? # include<iostream> using namespace std; void arraySome (int[), int, int); int main () const int arraysize = 10; int a[arraysize]-1,2,3,4,5, 6,7,8,9,10 cout << "The values in the array are:" << endl; arraySome (a, 0, arraySize) cout<< endl; system ("pause") return 0; void arraySome (int b[], int current, int size) if (current< size) arraySome (b, current+1, size); cout << b[current] <<""; a) Print the array values b) Double...

  • What is the value of  result after the following code executes?   int a = 60; int b...

    What is the value of  result after the following code executes?   int a = 60; int b = 15; int result = 20; if (a = b) result *= 3; 30 20 60 10 code will not execute The numeric data types in C++ can be broken into two general categories which are integers and floating-point numbers singles and doubles real and unreal numbers numbers and characters numbers and literals Which line in the following program will cause a compiler error?...

  • What is wrong with the following code snippet? int main() { int width = 10; height...

    What is wrong with the following code snippet? int main() { int width = 10; height = 20.00; cout << "width = " << width << " height = " << height << endl; return 0; } The code snippet uses an uninitialized variable. The code snippet uses an undefined variable. The code snippet attempts to assign a decimal value to an integer variable. The code snippet attempts to assign an integer value to a decimal variable.

  • What is the output from running the following code snippet. void mystery(Queue<int>& q) { Stack<int> s;...

    What is the output from running the following code snippet. void mystery(Queue<int>& q) { Stack<int> s; while (!s.isEmptyQueue()) { s.push(q.front()); q.deleteQueue(); } while (!s.isEmptyStack()) { q.addQueue(2 * s.top()); s.pop(); } } Queue q; q.addQueue(8); q.addQueue(4); q.addQueue(18); q.addQueue(7); q.addQueue(5); mystery(q); cout << "["; while (!.isEmptyQueue()) { cout << " " << q.front(); } cout << " ]" << endl;

  • What is the output of the following code? int num = 17;                           //Line 1 double...

    What is the output of the following code? int num = 17;                           //Line 1 double gpa = 3.85;                  //Line 2 bool done;                               //Line 3 done = (num == static_cast<int>( (2 * gpa + 9.3)));    //Line 4 cout << "The value of done is: "<< done << endl;     //Line 5

  • Example (4) Trace the following program and find the output >> SOURCE CODE #include <iostream.h> int...

    Example (4) Trace the following program and find the output >> SOURCE CODE #include <iostream.h> int main0 // define two integers int x-3; int y = 4; //print out a message telling which is bigger if (x >y) i cout << "x is bigger than y" << endl: else cout << "x is smaller than y" << endl; return 0; Example (5) Write a C++ program that takes from the user a number in SR (Saudi Riyal) then the program...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT