w3resource

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

C++ Basic: Exercise-1 with Solution

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

C++ Code Editor:

Previous: C++ Basic Exercises Home
Next: Write a program in C++ to print the sum of two numbers.

What is the difficulty level of this exercise?



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/cpp-exercises/basic/cpp-basic-exercise-1.php