Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assume a string object has been defined as follows: string description; Write a

ID: 3687539 • Letter: A

Question

Assume a string object has been defined as follows: string description; Write a cin statement that reads in a one word description. Write a statement that reads in a description that can contain multiple words separated by blanks. Write a definition statement for a character array large enough to hold any of the following strings: "Billy Bob's Pizza" "Downtown Auto Supplies" "Betty Smith School of Architecture" "ABC Cabinet Company" Assume the array name is defined as follows: char.name[25]; Using a stream manipulator, write a cin statement that will read a string will read a string into name, but will read no more characters than name can hold. Using the getline function, write a cin statement that will read a string into name but that will read no more characters than name can hold. Assume the following variables are defined: int age; double pay; char section; Write a single cin statement that will read input into each of these variables. What header files must be included in the following program? int main()

Explanation / Answer

Here is the code for you:

#include <iostream>
using namespace std;
int main()
{
string description;
cin>>description;   //Reads a single word description.
cout<<"A word description is: "<<description<<endl;
getline(cin, description);   //Reads a multiple word description, separated by spaces.
cout<<"A multiple word description is: "<<description<<endl;
char description2[35];   //Definition statement large enough to hold the given strings.
char name[25];
fgets(name, 25, cin); //Read string into name that will read no more than 25 characters.
int age; double pay; char section;
cin>>age>>pay>>section;   //Read age. //Read pay. //Read section.
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote