C++ Program to Print a Sentence on Screen

  • Write a program in C++ to print a sentence a screen using cout.
  • How to print a sentence in C++.
  • 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

Related Topics
C++ Program to Find Quotient and Remainder
C++ Program to Check Whether a Character is Vowel or Consonant.
C++ Program to Find All Square Roots of a Quadratic Equation
C++ Program to Find Size of Int, Float, Char and double data types
C++ Program to Find Factorial of a Number
C++ Program to Reverse Digits of a Number
C++ Program to Check Leap Year
C++ Program to print ASCII Value of All Alphabets
C++ Program to Find Power of a Number
List of all C++ programs