Hi Anurag Sharma!
Air quotes, also called finger quotes, are virtual quotation marks formed in the air with one's fingers when speaking.

It could be ironic or may be intended to mock somebody or be sarcastic.
While the term air quotes did not appear until 1989, use of similar gestures has been recorded as early as 1927.
But this lesson portrays the positive implementation and how strings can be introduced into the programs.
The remaining literals are String literals and Boolean literals. Let us dive into to know about them.
The string literals are same as the character literals.
The main difference between character literals and string literals is that the string literals are enclosed in double quotes.
For example, "This is an example of string literal" .
A string literal also can accommodate special characters and escape sequences mentioned in the previous lesson.
Consider the given code below.
1. #include <iostream>
2. int main()
3. {
4. std::string str="I am learning C++ literals.";
5. std::cout<<str;
6. }
As you see in line 4, string literal "I am learning C++ literals." is stored into str of type std::string.
std::string is a way to present sequence of characters as an object of class. This class is called std::string. As of now, you can consider it as a data-type to store multiple characters. We will learn more about this later.
1. #include <iostream>
2. int main()
3. {
4. std::string str="I am learning C++ literals.";
5. std::cout<<str;
6. }
Line 5 prints str. This prints the literal that we have stored in str.
Hence, the output will be

Please predict the output of the following :
#include <iostream>
int main()
{
std::cout<<"\"Hi "
"all " "can you tell""me, what I will print\"";
}

Brilliant job! You got the right answer.
This is exactly what I was looking for.
Do you want to know the logic behind this answer?

Now, let us try another question.
Now, let us try another question.
#include <iostream>
int main()
{
std::cout<<"\"Hi " \
"all " "can you tell""me, what I will print\"";
}

Wonderful! your answer is right.
I must say, well done.
Do you want to know the logic behind the answer?

This is all about string literals. Now let us know about Boolean literals.

There are two Boolean values in C++. They are true and false.
Please predict the output of the following code.
#include <iostream>
int main()
{
bool isTrue=true;
bool isFalse=false;
std::cout<< "This PRINTS " << isTrue << "\n";
std::cout<< "And this prints "
<< isFalse << "\n";
}
Great ! You got it right.
I appreciate your thinking.

Kudos to you! You consistently bring your all and I truly appreciate that.
Do you want to know the logic behind the answer?

Let us have a quick revision on string literals and Boolean literals.

Catch you in the next lesson. Bye.
Comments
Post a Comment