Sample Widget

C v/s C++

1) Comments :- 
 
 'C' supports only block comment while C++ support block comment
  as well as line comment.
 
2) Type Casting :- 
 
 'C'       Style  :  (float)x         // C++ also support this style too.

  'C++'   Style  :  float(x)
 
3) Length of variable names :- 
 
ANSI 'C' allow to have any number of characters in the variable but 
consider only first 32 of them.
 
 'C++' also allow to have any number of charaters in the variable name 
with all of them being significant.
 
4) Data Declaration :- 
 
'C' strictly requires variables to declared at the beginning of the scope
 before the first executable statement, 
 While 'C++' allows to declered variable anywhere in the scope, also
at the place of its first use.
 
                for(int k=0;k<=rows;k++)

                {

                     for(int m=0;m<=cols;m++)

                     {

                     }

                 }

                 k=2;           // right b'cos k is declared outside of the scope

                 m=2;          // wrong b'cos m is declared inside the scope 
 
6) Type Compatibility :- 
 
'C++" is very strict with regard to type compatibility, 
while 'C'  is  not so strict.
 
                                            char x='A';
 
                                            int i,j,k;
 'C' treats character
  constant as integer      i=sizeof(char);
 
 'C++' treats charater      j=sizeof(x);
 constant as character
                                            k=sizeof('A')
 
7) Symbolic Constants :-
 
a) Similarities :-  
 
(i) Both 'C' and 'C++' use the keyword 'const' for declaring
 symbolic constants and in both 'C' 
     

Visitors

About Me

I am working as computer teacher in Ambuja School