C++ Program to Print a Sentence on Screen

In the previous article, we have discussed C++ Program to Calculate Average Percentage Marks. In this article, we will see C++ Program to Print a Sentence on Screen.

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 court.

C++ program to print a sentence on screen

C++ program to print a sentence on screen 2

#include <iostream>
 
using namespace std;
 
int main() {
    cout <<"BTech Geeks";
    return 0;
}

Output

BTech Geeks

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.

C++ program to print a multi line sentence on screen 2

#include <iostream>
 
using namespace std;
 
int main() {
    cout << "BTech Geeks"<< endl <<"C++ Programs\n"<<"Thank You";
    return 0;
}

Output

BTech Geeks
C++ Programs
Thank You

Coding in C++ Programming language helps beginners & expert coders to use the classes for various concepts programs. So, look at the C++ Code Examples of all topics and write a logic with ease.