Contenido del Curso
Introduction to C++
Introduction to C++
New Lines
As it is mentioned before the object cout
doesn’t give us the opportunity to start the message from a new line. So what should we do if we want to print the message or data to separate lines?
To insert a new line you can use endl
manipulator:
#include <iostream> using namespace std; int main() { cout << "I love programming!" << endl; cout << "I love C++" << " and " << "Python!"; return 0; }
As a more compact alternative to endl
you can also use \n
character:
#include <iostream> using namespace std; int main() { cout << "I love programming! \n" << endl; cout << "I love C++"; return 0; }
To create a blank line just use twice character \n after each other.
If you want to insert double quote characters to your message you can also use here the backslash
\"
.
Tarea
Print two messages: "Hello!"
and "I love C++!"
separating them by a blank line:
- Print the message "Hello!" with twice character \n.
- Print the message "I love C++!".
Don’t forget about semicolon ;
at the end of both these statements.
¡Gracias por tus comentarios!
New Lines
As it is mentioned before the object cout
doesn’t give us the opportunity to start the message from a new line. So what should we do if we want to print the message or data to separate lines?
To insert a new line you can use endl
manipulator:
#include <iostream> using namespace std; int main() { cout << "I love programming!" << endl; cout << "I love C++" << " and " << "Python!"; return 0; }
As a more compact alternative to endl
you can also use \n
character:
#include <iostream> using namespace std; int main() { cout << "I love programming! \n" << endl; cout << "I love C++"; return 0; }
To create a blank line just use twice character \n after each other.
If you want to insert double quote characters to your message you can also use here the backslash
\"
.
Tarea
Print two messages: "Hello!"
and "I love C++!"
separating them by a blank line:
- Print the message "Hello!" with twice character \n.
- Print the message "I love C++!".
Don’t forget about semicolon ;
at the end of both these statements.
¡Gracias por tus comentarios!
New Lines
As it is mentioned before the object cout
doesn’t give us the opportunity to start the message from a new line. So what should we do if we want to print the message or data to separate lines?
To insert a new line you can use endl
manipulator:
#include <iostream> using namespace std; int main() { cout << "I love programming!" << endl; cout << "I love C++" << " and " << "Python!"; return 0; }
As a more compact alternative to endl
you can also use \n
character:
#include <iostream> using namespace std; int main() { cout << "I love programming! \n" << endl; cout << "I love C++"; return 0; }
To create a blank line just use twice character \n after each other.
If you want to insert double quote characters to your message you can also use here the backslash
\"
.
Tarea
Print two messages: "Hello!"
and "I love C++!"
separating them by a blank line:
- Print the message "Hello!" with twice character \n.
- Print the message "I love C++!".
Don’t forget about semicolon ;
at the end of both these statements.
¡Gracias por tus comentarios!
As it is mentioned before the object cout
doesn’t give us the opportunity to start the message from a new line. So what should we do if we want to print the message or data to separate lines?
To insert a new line you can use endl
manipulator:
#include <iostream> using namespace std; int main() { cout << "I love programming!" << endl; cout << "I love C++" << " and " << "Python!"; return 0; }
As a more compact alternative to endl
you can also use \n
character:
#include <iostream> using namespace std; int main() { cout << "I love programming! \n" << endl; cout << "I love C++"; return 0; }
To create a blank line just use twice character \n after each other.
If you want to insert double quote characters to your message you can also use here the backslash
\"
.
Tarea
Print two messages: "Hello!"
and "I love C++!"
separating them by a blank line:
- Print the message "Hello!" with twice character \n.
- Print the message "I love C++!".
Don’t forget about semicolon ;
at the end of both these statements.