Question

1) As mentioned in this chapter, C++ predefined identifiers such as cout and cin can be...

1) As mentioned in this chapter, C++ predefined identifiers such as cout and cin can be redefined by the programmer. However, why is it not wise to do so?

(2) The text mentioned that the char data type can be cast into an int. What are some possible uses of this functionality?

(3) Introduce the C++ data type string, which is a programmer-defined data type available in the C++ library. Define a string as a sequence of zero or more characters.

Homework Answers

Answer #1

Answer 1:

we can redefine the cin and cout with own definitions but original functionality will break. So it is not adviced to do

Answer 2:

when ever we want perform the operations on the ASCII values we will convert it into int and perform the operations.if we want perform any arithmetic operations on chars we will convert it into int and do it

Answer 3:

striing line="Hello World";

#include <iostream>
using namespace std;
int main()
{
string line="Hello World";
cout<<line;
return 0;
}

Know the answer?
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
Similar Questions
c++ please The only outside functions you can use are: a) cout, cin, rand(), srand(), and...
c++ please The only outside functions you can use are: a) cout, cin, rand(), srand(), and time() b) functions you write yourself Q3) convert character digit to number CharToNum('0') ==> 0 CharToNum('9') ==> 9 int CharToNum(const char c) { }
Write a 4-6 sentence summary explaining how you can use STL templates to create real world...
Write a 4-6 sentence summary explaining how you can use STL templates to create real world applications. In your summary, provide an example of a software project that you can create using STL templates and provide a brief explanation of the STL templates you will use to create this project. After that you will implement the software project you described . Your application must be a unique project and must incorporate the use of an STL container and/or iterator and...
In this exercise you're going to implement a graph class using an adjacency matrix of size...
In this exercise you're going to implement a graph class using an adjacency matrix of size 26x26. This allows up to 26 vertices, which will be denoted by the uppercase letters A .. Z. Initially a graph is empty, and then vertices and edges are added. Edges are directed, and have weights. Example: (A, B, 100) denotes an edge from A to B with weight 100; there is no edge from B to A unless one is explicitly added. A...
c++ program can you please explain how it works and the process? Question: You will design...
c++ program can you please explain how it works and the process? Question: You will design a program in C++ that plays hangman using classes (polymorphism and inheritance).... Hangman Game CODE: #include <iostream> #include <cstdlib> #include<ctime> #include <string> using namespace std; int NUM_TRY=8; //A classic Hangman game has 8 tries. You can change if you want. int checkGuess (char, string, string&); //function to check the guessed letter void main_menu(); string message = "Play!"; //it will always display int main(int argc,...
1. In C++, programmers can use a class to create a large number of instance variables...
1. In C++, programmers can use a class to create a large number of instance variables of the class's type. Group of answer choices True False 2. When a C++ programmer declares a function, they are required to state all of the following except Group of answer choices {} The type of data, if any, returned by the function The function name The type of data, if any, sent to the function 3. When a C++ programmer calls a function,...
Strings The example program below, with a few notes following, shows how strings work in C++....
Strings The example program below, with a few notes following, shows how strings work in C++. Example 1: #include <iostream> using namespace std; int main() { string s="eggplant"; string t="okra"; cout<<s[2]<<endl; cout<< s.length()<<endl; ​//prints 8 cout<<s.substr(1,4)<<endl; ​//prints ggpl...kind of like a slice, but the second num is the length of the piece cout<<s+t<<endl; //concatenates: prints eggplantokra cout<<s+"a"<<endl; cout<<s.append("a")<<endl; ​//prints eggplanta: see Note 1 below //cout<<s.append(t[1])<<endl; ​//an error; see Note 1 cout<<s.append(t.substr(1,1))<<endl; ​//prints eggplantak; see Note 1 cout<<s.find("gg")<<endl; if (s.find("gg")!=-1) cout<<"found...
USING C++ Topics: Friend functions Copy constructor ----------------------------------------------------------------------------------------------------------------------------------------- Lab 3.1 Create your objects in the stack...
USING C++ Topics: Friend functions Copy constructor ----------------------------------------------------------------------------------------------------------------------------------------- Lab 3.1 Create your objects in the stack (not on the heap). Add a friend function, kilotopound, which will convert kilograms to pounds. Change your weight mutator to ask whether weight is input in kilograms or pounds. If it is kilograms, call the friend function kilotopound to convert it to pounds and return pounds. There are 2.2 pounds in one kilogram. Create an object on the stack with the following information:     ...
C++ Programming Given int ages={7,12,9,6 }; What will be the output statement: cout<<ages; This will display...
C++ Programming Given int ages={7,12,9,6 }; What will be the output statement: cout<<ages; This will display a compiler error 7,12,9,6 0 A hex value Char course [20]=”Intro to c++” ; what character at course[12] will be: \0 A hex value + A space Given char course [20]={ “Intro to c++”}; the character at course[6] will be: \0 The letter o The letter t A space In the following two dimensional Array table [4][3]= {3,7,0,2,4,9,8,1,3,6,5,4}; What is the value of table...
MUST WRITE IN C++ Objective: Learn how to design classes using abstract classes and inheritance Assignment:...
MUST WRITE IN C++ Objective: Learn how to design classes using abstract classes and inheritance Assignment: MUST WRITE IN C++ Objective: Learn how to design classes using abstract classes and inheritance Assignment: In cryptography, encryption is the process of encoding a message or information in such a way that only authorized parties can access it. In this lab you will write a program to decode a message that has been encrypted using two different encryption algorithms. Detailed specifications: Define an...
In the following C code, Which variable if NOT of primitive data type? A. a B....
In the following C code, Which variable if NOT of primitive data type? A. a B. b C. c D. d int a = 10; double b = 20.0; float c = false; char d[5] = "Hello"; // here we define a string In programming language C, the implementation of a string data type is limited dynamic length, which means the length of a string variable is fixed once it has been defined. A. True B. False In C# programming...