C++ Program to Print a Sentence on Screen

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
C++ Program for Input and Output of Integer
C++ Taking Input From User
C++ Program to Print Hello World
C++ Program to find length of string
C++ Program to Find Average of Numbers Using Arrays
C++ Program to Swap Two Numbers
C++ Program to Generate Random Numbers
C++ Program to Check Strings are Anagram or Not
C++ Program to Find GCD of Two Numbers
C++ Program to Convert Fahrenheit to Celsius
C++ Program to Find Largest of Three Numbers
All C++ Programs