Write code that dynamically allocates an array of n integers (number of integers
ID: 3837432 • Letter: W
Question
Write code that dynamically allocates an array of n integers (number of integers is provided by the user). The following if statement determines whether choice is equal to 'Y' or "Y". if (choice =='y' || choice == 'Y') How this statement can be simplified (using just one condition) using the characters and string functions? Propose a new statement. Assume str1 and str2 are string class objects. A. Write a C++ statement to store in str3 the contents of str1 and str2. B. Write code that displays "They are the same!" if the two objects (str1 & str2) contain the same string. Write a C++ statement to determine the length of str3 using a string class member function to do it and stored this value to variable z.Explanation / Answer
The answers that u have written are correct only but in the bit B a small change whenever u are comparing two things to now their equality then u need to use "==" not "="
And for c) answer is
Str3 ="some string"
We can find the length by using length() function so after finding the length we are assigning this value to a variable called z
So str3="somestring";
Z=str3.length();
6)answer is by using string function
If(choice. equalsIgnoreCase("y"))
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.