Lorem ipsum dolor sit amet, consectetur adipiscing elit. Test link
Posts

2.1 Structure of program

1 min read
/* This Program prints Hello World on screen */
#include <iostream.h>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}

1 . /* This program ... */
The symbols/* and*/ used for comment. This Comments are ignored by the compiler, and are used to provide useful information  about program to humans who use it.

2. #include <iostream.h>
This is a preprocessor command which tells compiler to include iostream.h file.

3. using namespace std;
All the elements of the standard C++ library are declared within what is called a namespace, the namespace with the name std. So in order to access its functionality we declare with this expression that we will be using these entities. This line is very frequent in C++ programs that use the standard library.

4. main()
C++ programs consist of one or more functions. There must be one and only one function called main. The brackets following the word main indicate that it is a function and not a variable.

5. { }
braces surround the body of the function, which may have one or more instructions/statements.

6. Cout<<
it is a library function that is used to print data on the user screen.

7. ''Hello World'' is a string that will be displayed on user screen

8. ; a semicolon ends a statement.

9. return 0; return the value zero to the Operating system.

                      3.1 Variables          NEXT >>

You may like these posts

  • C++ allows us to create own own data types. enumerated type is the simplest method for doing so. An enumerated type is a data type where every possible value is defined as a s…
  • In most program environments, the standard input by default is the keyboard, and the C++ stream object defined to access it is cin. cin is an instance of iostream class For f…
  • The predefined object clog is an instance of ostream class. The clog object is said to be attached to the standard error device, which is also a display screen but the object…
  • On most program environments, the standard output by default is the screen, and the C++ stream object defined to access it is cout. cout is an instance of iostream class …
  • The predefined object cerr is an instance of iostream class. The cerr object is said to be attached to the standard error device, which is also a display screen but the objec…
  • References are another variable type of C++ that act as an alias or short name to another variable. A reference variable acts just like the original variable it is referencin…

Post a Comment