Every programming language has its own file extension. For C programs, generally we use .C file extension. Similarly, for C++ programs we use .CPP file extension.
Consider the following c program which can run under popular compilers without any difficulty.
Standard library function ‘print’ does not require any header files i.e., c language has default header . But in cpp we have to include header file to use it i.e., there is no default header file in cpp.
Here, there are two types of streams:
Input stream: For accepting the data.
Output stream: For displaying the data.
In cpp, ‘cin’ object is used to accept data. The object is included in the header . There is no need of explicit address operator and control string character.
cout<<”Value entered is “<<a;
Value entered is 20
In cpp the output is displayed using ‘cout’ object. The object is included in the header . The major advantage of ‘cout’ object is that there is no need of string characters such as %d, %c, %s, etc.
cout<<”The value is “<<a;
The value is 10
In cpp, you have new types of comment lines. These new comments start with ‘//’. Characters after ‘//’ are considered as comment lines and these are called single lined commands. Cpp even allows both /*,*/.
//This is a single lined comment line.
/*This is a
multi lined comment line.*/
cpp allows declaration of constants with the help of #define_______.
constant data_type variable
Scope resolution operator:
To get the idea of what is a scope resolution operator, let us suppose a program.
Here the output should be 200. But we cannot access the global value of a. So in cpp this is being overcome by using a scope resolution operator (::).
we don’t have any chance to accers the global variable in traditional’c’ language but in c++,u can access u can access global variable.
:-scope resolutions operator in cpp distingistes global variable and local variable when both are declared with similar name
cout<<”Value of local a is “<<a;
cout<<”Value of global a is “<<::a;
Value of local a is 100
Value of global a is 10
C#(CSHARP) is easy to learn.It can be used to create almost anything but is particularly strong at building Windows desktop applications and games. This can also be used to develop web applications and has become increasingly popular for mobile development .