Small Steps I — Creating with Text and Numbers
Including quotes and newlines
Print A and B on different lines with a single `print` call.
What you will learn
Use escape sequences beginning with a backslash to include special characters in a string.
Try it
Example · example.cpp
void small_main()
{
print("Hello\nSmall");
print("\"Hi\"");
}
\n represents a newline, \" one double quote, and \\ one backslash. Although written with two symbols in code, each represents one character.
"" is an empty string; " " contains one space. Even when print outputs an empty string, it adds a newline at the end.
Expected output:
Hello
Small
"Hi"
Exercise
Print A and B on different lines with a single print call.
Exercise starter · exercise_starter.cpp
void small_main()
{
print("Hello\nSmall");
print("\"Hi\"");
}
Hint
Change the parts of the example that you need.
show solution
void small_main()
{
print("A\nB");
}