Desired output:
Hello world!
Zeeshan says, "It's I who can do it!"
What is the length of the string
My_Stng
used to print, exactly, the above statement using
cout<<My_Stng;
command only once?
Details and Assumptions :
Space
is also considered as a character.
There is no space before or after both the statements.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
The above code script gives you the desired output, to get the length of that string, simply, use the builtin function
length()
with string name asMy_Stng.length()
. Actually,cout<<"Hello world!";
is enough to print"Hello world!"
, but to print a new line, a character\n
is used. Moreover, if you want to print the character"
, you have to use a slash\
with it to avoid an error because that symbol"
is both the starting and the ending of a string.Compilers treat both
\n
and\"
as a single character. HenceMy_Stng.length()
returns 5 0 .