First Program In C++ For Beginners – Interesting!!!

Let us look at how to create a first code in C++, mainly for beginners. To write hello world, the below command or syntaxes can be followed sequentially:
Line 1
#include <iostream>

Line 2

Line 3
int main( ) {


Line 4
Std::cout << “hello, world!” << std::endl;


Line 5
return 0;


Line 6
}

 

Summary

#include <iostream>

int main ( ) {
std::cout << “Hello, World! << std::endl;
return 0;
}


NOTE:


In addition, compiling the aforementioned program and at the same time run it, you will need the C++ compiler such as the GCC or the Clang.


Follow the below steps when compiling the above program into something meaning:


1.
Make sure you save the entire code using the .cpp file extension, so for example, hello.cpp


2. You need to open the terminal or the command prompt and move to the entire directory where the file is saved


3. Ensure to compile the program using the syntax or a command, that is gcc hello.cpp –o hello


4.
Make sure to run the program using ./hello


Meanwhile, the Clang can also be used to compile and run the program, follow the below steps:


1. Save the file or the code with the .cpp extension


2. Explore the terminal or the command prompt


3. Compile the application or the program using clang++ hello.cpp –o hello

4. Run the application now using the right command that is ./hello

About Author


Discover more from SURFCLOUD TECHNOLOGY

Subscribe to get the latest posts sent to your email.

Leave a Reply

Your email address will not be published. Required fields are marked *

Discover more from SURFCLOUD TECHNOLOGY

Subscribe now to keep reading and get access to the full archive.

Continue reading