C++ is a general purpose programming language. When
you write a code for C++ remember to save it with .cpp file extension where .c
file extension will work with C language. Now C++ is more flexible and efficient
then C. In the first stage we will write a program about how to print something
in C++ language. We will print simple “Hello World!” .Now let’s write the code
and then we will know more about it
#include <iostream
>
using
namespace std;
int main()
{
cout<<"Hallo World!";
return 0;
}
Now let me
describe this code. Here "#include" is called
Processor Directive and " iostream " is a
header file for C++. A Header file contain the description about
functions it holds. Now Here “using namespace std;” is written for
avoiding name space collision. It is done by localizing names of identifier. “std”
is the name space.
Here “main()” is the main function. Every program must hold not
more than one main function. Execution of the program start from main function.
The open close bracket with main function “()” is called parenthesis. Here “int
main()” says that the main function is an integer type. An integer type
function must return something, but in this program we are not going to return
some value so we write “return 0” for that.
The open close bracket after main “{}” which will says that the
body of main function is written inside this brackets.
Now inside the body we found that “cout < <”Hello World”;” where cout
is a standard C++ function. This function is work for printing some outputs. If
you want to use “cout” write it in this format – “cout<<”Your Text Here”;”
then any this you write replacing “Your Text Here” will be printed.
Now we know the basic of C++, Let us print the output of above
program.
Hello world!
So you successfully run your first stage of
coding.

0 comments:
Post a Comment