Question

Given the following declaration code: char *fullName="Sonny Bono"; char *parts=fullName; __________________ cout << parts; Which line...

Given the following declaration code:

char *fullName="Sonny Bono";
char *parts=fullName;
__________________
cout << parts;

Which line of code when put on the blank line will cause Bono to be printed to the screen? Assume there is 1 space between Bono and Sonny and the space should NOT be a part of the output.

1) fullName=new char[6];

2) parts += 6;

3) parts = fullName[6];

4) parts = fullName + 7;

5) parts = &fullName + 6;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

As the parts variable represents the fullname (It points to it's address)

if we add parts 6 to it's pointer the address points to B

when we print it it will print Bono

Option 1 is not syntactically correct

Option 2 is correct

Option 3 we cannot assign value to a pointer

Option 4 will print ono

option 5 is also not possible

Add a comment
Know the answer?
Add Answer to:
Given the following declaration code: char *fullName="Sonny Bono"; char *parts=fullName; __________________ cout << parts; Which line...
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
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