Question

2. Given the code below: int vals t1 (4.7,11). valPtr valPtr-vals What is the output of the following statements, if it is an address, indicate that: a. cout (1valPtr) F c. cout << (valPtr2); e. cout <<*(valPtr0) cout << True cout << False cout << True cout << False cout << True cout << False, ㄱ Hip else g. if (valPtr&valPtr [1]) else h. if (valPtr (4] &valPtr [1]) else Write this code in c++ and screen shot the code
0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>

using namespace std;

int main () {
   int vals[] = {4,7,11}, *valPtr;
   valPtr = vals;
   
   cout<<*(1+valPtr);
   cout<<endl;
   
   cout<<(valPtr+0);
   cout<<endl;
   
   cout<<(valPtr+2);
   cout<<endl;
   
   cout<<*(valPtr+0);
   cout<<endl;
   
   if(&valPtr[0] > &valPtr[1])
      cout<< "True";
   else
      cout<<"False";
   cout<<endl;
   
      
   if(valPtr > &valPtr[1])
      cout<< "True";
   else
      cout<<"False";
   cout<<endl;
   
   if(&valPtr[4] > &valPtr[1])
      cout<< "True";
   else
      cout<<"False";
   cout<<endl;
      
   return 0;
}

Output:

2 Qx22fe30 0x22fe38 4 False False lrue Process exited after 0.06326 seconds with return value 0 Press any key to continue . - -

Please upvote the solution if it helped. Thanks!

Add a comment
Know the answer?
Add Answer to:
Write this code in c++ and screen shot the code 2. Given the code below: int...
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 15 After the following code executes, what is the output if user enters 0? int...

    Question 15 After the following code executes, what is the output if user enters 0? int x =-1; cout << "Enter O or 1:"; cin >> X; if (x) cout << true else cout << false O nothing will be displayed true O false 0

  • What is the output of the following C++ code? int count = 1; int num =...

    What is the output of the following C++ code? int count = 1; int num = 25; while (count < 25) { num--; count++; } cout << count « " " « num << endl i 25 1 0 24 1 0 25 0 0 24 0 In this while loop statement, while (counter < 10), where counter is an int variable. Which statement below is an equivalent way to write this while statement? while (10 < counter) while (9...

  • 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...

  • points): Show the output of the code below as it would appear on the monitor. int...

    points): Show the output of the code below as it would appear on the monitor. int main cout <<" <<endl: int wildcat 2: while (wildcat > 5) cout << wildcat <<endl; wildcat++ cout <K*<< endl; int jayhavk 5i do cout << jayhawk <s endl: while (jayhawk0) cout <<*" << endl; int wolverine l: while (wolverine 0 &&wolverine < 10) cout << wolverine <<endl: wolverine2: cout <<" <<endl: for (int zag-4; zag>0; zag_) cout <<****" << endl; for (int i-10; i<-30;...

  • What will the output be in the following? int a, b, c; a-b-0; c 5; ific<...

    What will the output be in the following? int a, b, c; a-b-0; c 5; ific< 1011 (a = = 0 &&b != 0)) 3. cout<<True"; else cout<<"False", What will the output be in the following? a. int icount; 4. do count = 0; cout<<"The count is "<cicount<<endl; while(icount<10); int count = 0; do b. cout<<"The count is “<<count<<endl; while++icount<10); c. for(int n 5; n>0; n-) cout<<n;

  • I need someone to code this up in C , and show the screen shot shot...

    I need someone to code this up in C , and show the screen shot shot of the output for some input Design an amplitude modulation scheme that will generate the amplitude modulated signal yAM(t) ct)m(t)c(t) where c(t) sin 2rFd is the carrier with carrier frequency F, and m(t)-A,n sin 2πFmt is the modulating signal with amplitude Am and modulating frequency Fm. For initial values you may assume that Fc-6 kHz, Fm-400 Hz and Am-1.

  • How do can I update this code (Code A): Code (A) #include using namespace std; int fibonacci(int n) { int a = 0,...

    How do can I update this code (Code A): Code (A) #include using namespace std; int fibonacci(int n) { int a = 0, b = 1, c; if (n <= 1) return n; for (int i = 2; i <= n; i++) { c = a + b; a = b; b = c; } return b; } int fibonacciRecursive(int n) { if (n <= 1) { return n; } return fibonacciRecursive(n-1) + fibonacciRecursive(n-2); } int main() { int n;...

  • QUESTION 7 Which of the following is a valid C++ assignment statement? (assume each letter is...

    QUESTION 7 Which of the following is a valid C++ assignment statement? (assume each letter is a different variable) A.y=b-c B.y +z = x C.x = a bi D.x = -(y*z): Ex = (x + (y z): QUESTION 8 Which of the following is a valid variable name according to C++ naming rules? A 2ndName B.%Last_Name C@Month D#55 Eyear03 QUESTION 9 Which library must be included to enable keyboard input? A kbdin B. cstdlib C input Diostream E lomanip QUESTION...

  • (a) Consider the following C++ function: 1 int g(int n) { 2 if (n == 0)...

    (a) Consider the following C++ function: 1 int g(int n) { 2 if (n == 0) return 0; 3 return (n-1 + g(n-1)); 4} (b) Consider the following C++ function: 1 bool Function (const vector <int >& a) { 2 for (int i = 0; i < a. size ()-1; i ++) { 3 for (int j = i +1; j < a. size (); j ++) { 4 if (a[i] == a[j]) return false; 5 6 } 7 return...

  • what is the output of the following code segment? C++ g. int arr[3][4]; for (int i...

    what is the output of the following code segment? C++ g. int arr[3][4]; for (int i = 0; i < 3; i++) for (int j = 0; j < 4; j++) arr[i][j] =i*4 + j; for (int i = 0; i < 3; i++) for (int j = 0; j < 4; j++) cout << arr[i][j] << " "; h. int next(int & x) { x= x + 1; return (x + 1); int main() { int y = 10;...

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