Theoretically we simply have to put a cin statement to get data from a user and
ID: 3649120 • Letter: T
Question
Theoretically we simply have to put a cin statement to get data from a user and then put a cout statement to show the user the results of our calculations. There are a lot of reasons to give users specific instructions on what input we are requesting. Then there has to be an explanation as to what the user is seeing once the calculation is complete.If I ask a user to input a number I need to be more specific than that. Remember that Murphy is a good friend of ours and can always be counted on to help our users find a number that our program is not designed to cope with.
Also, remember the difference between data and information. The number 2 is data. Remember that information requires more than one piece of data or it requires some context to place the data in relation to other data. We have to provide that information.
You wouldn
Explanation / Answer
C++ provides convenient and powerful tools to manipulate strings. This tutorial shows some of the basic string manipulation facilities, with examples to illustrate their use. It also shows some extensions the C++'s string capabilities by making use of some of the Boost Library facilities. Strings and Basic String Operations Putting aside any string-related facilities inherited from C, in C++, strings are not a built-in data type, but rather a Standard Library facility. Thus, whenever we want to use strings or string manipulation tools, we must provide the appropriate #include directive, as shown below: #include using namespace std; // Or using std::string; We now use string in a similar way as built-in data types, as shown in the example below, declaring a variable name: string name; Unlike built-in data types (int, double, etc.), when we declare a string variable without initialization (as in the example above), we do have the guarantee that the variable will be initialized to an empty string — a string containing zero characters. C++ strings allow you to directly initialize, assign, compare, and reassign with the intuitive operators, as well as printing and reading (e.g., from the user), as shown in the example below: string name; coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.