Question

4. (8 pts) Given the following code snippet: I char c1 x, c2 y, c3 z; t char *pl &c1, *p2 &c3; 3chare c2; Tp2 w s p2 pl;
hi this is c++ i hope you can see but the number 3
is char &r = c2;
everything else looks readable
thank you
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Coding:

#include <iostream>
using namespace std;
int main()
{
char c1='x',c2='y',c3='z';
char *p1=&c1,*p2=&c3;
char &r=c2;
cout<<*p1<<", "<<*p2<<", "<<r<<endl;
*p2='w';
p2=p1;
p1=&c3;
r='w';
cout<<c1<<","<<c2<<", "<<c3<<endl;
cout<<*p1<<", "<<*p2<<", "<<r<<endl;
}

Norme Name astres nema Address Value nistes Name Address voso vano Value p1 10001 10001 10002 10002 10003 10003 OUTPUT AFTERPointer Name Variable Name Address Value Address Value p1 10001 10001 10002 10002 10003 10003 Final Output: c1x c2w c3w p1 va

- O X CA. C:\WINDOWS\system32\cmd.exe x, z, y X,W, W W, X, W Press any key to continue .... Output after first four line

if you still have any Problem regarding this question please comment and if you like my code please appreciate me by thumbs up thank you.........

Add a comment
Know the answer?
Add Answer to:
hi this is c++ i hope you can see but the number 3 is char &r...
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
  • Hi, I hope I can get some help with the following exercise in C++( CPP): 1.Write...

    Hi, I hope I can get some help with the following exercise in C++( CPP): 1.Write an additional method called push_back(int) that will add an integer to the end of the list. You can modify the provided code. 2.Modify the Node class and LinkedList class so that you can access your parent node (double linked-list). /* definition of the list node class */ class Node { friend class LinkedList; private: int value; Node *pNext; public: /* Constructors with No Arguments...

  • Hello I need help fixing my C++ code. I need to display in the console the...

    Hello I need help fixing my C++ code. I need to display in the console the information saved in the file as well have the content saved in the file output in a fixed position like the screenshot. Thanks. CODE #include<iostream> #include<fstream> #include<iomanip> using namespace std; //main function int main() {    //variable to store student id    int id;       //variables to store old gpa(ogpa), old course credits(occ), new course credits(ncc), current gpa(cur_gpa), cumulative gpa(cum_gpa)    float ogpa,...

  • Overview: In this course, you will be responsible for completing a number of programming-based assignments by...

    Overview: In this course, you will be responsible for completing a number of programming-based assignments by filling in the missing pieces of code. Learning to program in C++ requires developing an understanding of general programming concepts and learning the syntax of the C++ programming language. These exercises will build on each other and help you cultivate you programming knowledge. It is recommended that students do not limit their practice to just that which is graded. The more you write your...

  • //Need help ASAP in c++ please. Appreciate it! Thank you!! //This is the current code I have. #include <iostream> #include <sstream> #include <iomanip> using namespace std; cl...

    //Need help ASAP in c++ please. Appreciate it! Thank you!! //This is the current code I have. #include <iostream> #include <sstream> #include <iomanip> using namespace std; class googlePlayApp { private: string name; double rating; int numInstalls; int numReviews; double price;    public: googlePlayApp(string, double, int, int, double); ~ googlePlayApp(); googlePlayApp();    string getName(); double getRating(); int getNumInstalls(); int getNumReviews(); string getPrice();    void setName(string); void setRating(double); void setNumInstalls(int); void setNumReviews(int); void setPrice(double); }; googlePlayApp::googlePlayApp(string n, double r, int ni, int nr, double pr)...

  • Assignment Overview In Part 1 of this assignment, you will write a main program and several...

    Assignment Overview In Part 1 of this assignment, you will write a main program and several classes to create and print a small database of baseball player data. The assignment has been split into two parts to encourage you to code your program in an incremental fashion, a technique that will be increasingly important as the semester goes on. Purpose This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of...

  • Hi can you please show how you get the answers using the long way just so I can see how you worke...

    Hi can you please show how you get the answers using the long way just so I can see how you worked it out even if you can label which properties you've used Thank you 1. (a) (i) A student claims that if p and q are odd integers then the evaluation of the expression (p 1)(g2 - 1) will always be a multiple of 8. Give 3 numerical examples you would 2 marks) 3 marks) use to check this...

  • LC-3 Programming Help!! The Stack Protocol The following outline is the protocol for passing arguments to...

    LC-3 Programming Help!! The Stack Protocol The following outline is the protocol for passing arguments to a function and returning values. Everything is stored on the runtime stack so that space is used only when the function is executing. As a result the actual address of arguments and locals may change from call to call. However, the layout of the stack frame (activation record) is constant. Thus, the offests from the frame pointer (FP) to the parameters/locals are constant. All...

  • In this assignment, you will implement a sort method on singly-linked and doubly-linked lists. Implement the...

    In this assignment, you will implement a sort method on singly-linked and doubly-linked lists. Implement the following sort member function on a singly-linked list: void sort(bool(*comp)(const T &, const T &) = defaultCompare); Implement the following sort member function on a doubly-linked list: void sort(bool(*comp)(const T &, const T &) = defaultCompare); The sort(…) methods take as a parameter a comparator function, having a default assignment of defaultCompare, a static function defined as follows: template <typename T> static bool defaultCompare(const...

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