Hi Anurag Sharma!

+5 

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

+5 

Image result for air quotes

+5 

It could be ironic or may be intended to mock somebody or be sarcastic. 

+5 

While the term air quotes did not appear until 1989, use of similar gestures has been recorded as early as 1927.

+5 

But this lesson portrays the positive implementation and how strings can be introduced into the programs.

+5 

The remaining literals are String literals and Boolean literals. Let us dive into to know about them.

+5 

The string literals are same as the character literals.

+5 

The main difference between character literals and string literals is that the string literals are enclosed in double quotes.

+5 

For example, "This is an example of string literal" .

+5 

A string literal also can accommodate special characters and escape sequences mentioned in the previous lesson.

+5 

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.

+5 

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.

+5 
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.

+5 

Hence, the output will be


+5 

Please predict the output of the following :


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


Error

Hi all can you tell me, what I will print

"Hi all can you tell me , what I will print "

"Hi all can you tellme, what I will print"

+5 

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?


Yes No, I'm good

+5 

Now, let us try another question.

+5 

Now, let us try another question.


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


"Hi all can you tellme, what I will print"

Hi all can you tellme, what I will print

"Hi all can you tell me, what I will print"

Error

+5 

Wonderful! your answer is right.


I must say, well done.


Do you want to know the logic behind the answer?


Yes No, I'm good

+5 

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

+5 

Related image

+5 

There are two Boolean values in C++. They are true and false.

+5 

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";
}


This PRINTS true

And this prints false

This prints 1

And this prints 0

This PRINTS 1

And this prints 0

None of the above

+5 

Great ! You got it right.


I appreciate your thinking.

+5 

Kudos to you! You consistently bring your all and I truly appreciate that.



Do you want to know the logic behind the answer?


Yes No, I'm good

+5 

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

+5 

+5 

Catch you in the next lesson. Bye. 

Comments