Here is a C++ program to print a multi line string using cout. C++ program to print a sentence is one of the simplest programs. It is among the first few programs that many people write while learning a C++ programming language. This program helps in understanding basic syntax of C++ programming language.
The cout is the standard output stream which normally prints data on standard output (which by default is the screen). Here, we will see how to print a single line and multi line string using cout.
C++ program to print a sentence on screen
#include <iostream>
using namespace std;
int main() {
cout <<"Tech Crash Course";
return 0;
}
Output
Tech Crash Course
C++ program to print a multi line sentence on screen
We can either use endl or new line charcater '\n' to break a sentence and move to next line.
#include <iostream>
using namespace std;
int main() {
cout << "Tech Crash Course"<< endl <<"
C++ Programs\n"<<"Thank You";
return 0;
}
Output
Tech Crash Course C++ Programs Thank You
Recommended Posts