w3resource

C++ Exercises: Print a welcome text in a separate line


Welcome Text on Separate Line

Write a program in C++ to print welcome text on a separate line.

Visual Presentation:

C++ Exercises: Print a welcome text in a separate line

Sample Solution:

C++ Code :

#include <iostream> // Including the input-output stream header file

using namespace std; // Using the standard namespace

int main() // Start of the main function
{
    cout << "\n\n Print a welcome text in a separate line :\n"; // Outputting a welcome message with newlines
	cout << "----------------------------------------------\n"; // Outputting a separator line
    cout << " Welcome to \n" ; // Outputting a welcome message in a new line
    cout << " w3resource.com "<<endl ; // Outputting the website address and ending the line

} // End of the main function

Sample Output:

 Print a welcome text in a separate line :                             
----------------------------------------------                         
 Welcome to                                                            
 w3resource.com

Flowchart:

Flowchart: Print a welcome text in a separate line

For more Practice: Solve these Related Problems:

  • Write a C++ program to print a welcome message using multiple escape sequences so that each word appears on a separate line.
  • Write a C++ program that constructs the welcome text dynamically and prints it on separate lines using a loop.
  • Write a C++ program to store a welcome message in a character array and print it with embedded newline characters.
  • Write a C++ program to print a welcome message where the first and last parts are printed using different cout statements, each on a new line.

Go to:


PREV : C++ Basic Exercises Home
NEXT : Sum of Two Numbers.

C++ Code Editor:



Have another way to solve this solution? Contribute your code (and comments) through Disqus.

What is the difficulty level of this exercise?



Follow us on Facebook and Twitter for latest update.