Basic C++ Program to Print Hello World ! - KhurafatiTech How to Tips-Tricks

Recent

Thursday, June 2, 2016

Basic C++ Program to Print Hello World !


Basic C++  Program to Print Hello World !

download C++ source code file


here the text written after " // " or in between " /* " and " */ " is simply comment lines. compiler does not compile these lines, or we can say that these lines are not the part of program. we uses comments for making the program easy to read.

one line comment is written after " // "  and if we need comment of the lines more than one then we put the lines between" /* " and " */ "

" # " called the processor
" iostream"  is called  Input / Output stream
" using namespace std; "tells the compiler to use the std namespace
" int main() "  stands for ' main body of the program '
" return 0; " means ' the end of the program'
" cout<<" is the syntax for the output in C++, we used here HELLO WORLD in commas so it prints the text as it is written. we can write any text including characters, numbers it will print. If we do not use the commas it will give the value of the variable written just after " << "( here we didn't declare any variable, see it in the next programs , addition  or division )

the output in the above file is taken on the Ubuntu operating System. Before running the program, make sure that the compiler is  installed in your computer.
e.g.  for windows many  compilers are available , code block,
In Ubuntu  you can use g++ or code block.

for Installing g++ in Ubuntu just open the terminal using command line ctrl+T
and type sudo apt-get install g++ and hit Enter

No comments: