Saturday, 30 July 2016

Basic of C++

In this section we will cover the basic of c++,it will include the syntax ,variable,operators,loop types,pointers,references and information about other requirements of a c++ program.you will come across lot of terms that you have already studied in c language.

syntax and structure of c++ program

here we will discuss one simple and basic c++ program to print "HELLO " and  its structure in parts with details and uses .

first c++ program

#include<iostream.h>
using namespace std;
int main ()
{
cout<<"HELLO";

}  

HEADER FILES are included at the beginning just like in c program.A header file is a file with extension .h which contain c function declaration and macro definition to be shared between several source files.here iostream is a header file which provide us with input and output streams. Header files contained predeclared function libraries, which can be used by user for their ease.

USING NAMESPACE STD,tells the compiler to use standard namespace.Namespace collects identifier used for class,object and variables .Namespace can be used by two ways in a program,either by the use of using statement at the beginning , like we did in above mentioned program or by using name of namespace as prefix before the identifier with scope resolution (::) operator.

EXAMPLE- STD::COUT<<"A";

MAIN(),function is the entry point of execution in c++.its where the execution begins .it has got two argument like argc and argv which are command line argument accepted by the final exe.Basically main() is the function which holds the executing part of program its return type is  int.

COUT<<, is used to print anything on screen ,same as printf in c language .cin and cout are same as scanf and printf,only difference is that  you do not need to mention format specifiers like %d for int etc,in cout & cin

1 comment: