C++ files should be save with .cpp extension
C++ program start by first running the main function, so let’s add
int main()
{
}
Let’s make it proper function
int main()
{
return 0;
}
To print something on the screen we using
std::cout << “”;
But to use this we need to include the iostream file first, so let’s add it using following code
#include <iostream>
Now let’s add your message inside the double quotes
std::cout << “Welcome to C++!”;
Now let’s add a line break after the message
std::cout << “Welcome to C++!” << std::endl;
This will break the current line and move the cursor to the beginning of new line
Now you can add a line a code before the main function to avoid using std::
using namespace std;
Final code
#include <iostream>
using namespace std;
int main()
{
cout << “Welcome to C++!” << endl;
return 0;
}