Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 12

S.

No C C++
C++ is multi-paradigm. It supports both procedural
1 C follows the procedural style programming.
and object oriented.
In C++, you can use modifiers for class members to
2 Data is less secured in C.
make it inaccessible for outside users.
3 C follows the top-down approach. C++ follows the bottom-up approach.
4 C does not support function overloading. C++ supports function overloading.
5 In C, you can't use functions in structure. In C++, you can use functions in structure.
6 C does not support reference variables. C++ supports reference variables.
In C, scanf() and printf() are mainly used for C++ mainly uses stream cin and cout to perform
7
input/output. input and output operations.
8 Operator overloading is not possible in C. Operator overloading is possible in C++.
C programs are divided into procedures and C++ programs are divided into functions and
9
modules classes.
10 C does not provide the feature of namespace. C++ supports the feature of namespace.
Exception handling is not easy in C. It has to C++ provides exception handling using Try and
11
perform using other functions. Catch block.

12 C does not support the inheritance. C++ supports inheritance.


 A token is the smallest element of a program that is
meaningful to the compiler.

 Keywords
 Identifiers
 Constants
 Variables
 Keywords are pre-defined or reserved words in a
programming language.
 Each keyword is meant to perform a specific
function in a program.
 Since keywords are referred names for a compiler,
they can’t be used as variable names because by
doing so, we are trying to assign a new meaning to
the keyword which is not allowed.
auto for typedef
Const long volatile
double signed Char
float switch do
int void extern
Short case if
struct default Return
unsigned enum Static
Break Goto union
continue register while
else sizeof
 Identifiers are names given to different entries
such as variables, structures, and functions.
 Also, identifier names should have to be unique
because these entities are used in the execution of
the program
 You cannot use keywords as identifiers; they are
reserved for special use.
 Identifier naming conventions
1. Only alphabetic characters, digits and
underscores are permitted.
2. First letter must be an alphabet or underscore (_).
3. Identifiers are case sensitive.
4. Reserved keywords can not be used as an
identifier's name
 Constants are like a variable, except that their
value never changes during execution once
defined.
 There are two other different ways to define
constants in C++. These are:
 By using const keyword
 By using #define preprocessor
 Declaration of a constant :
const [data_type] [constant_name]=[value];
 A variable is a named memory location that stores
data
 When using a variable you refer to memory
address of computer
[data_type] [variable_name];
Data types specify the type of data that a variable
can hold.
 A reference variable is an alias, that is, another
name for an already existing variable.
 Once a reference is initialized with a variable,
either the variable name or the reference name
may be used to refer to the variable
 Creating References in C++
Think of a variable name as a label attached to the
variable's location in memory.
You can then think of a reference as a second label
attached to that memory location.
Therefore, you can access the contents of the
variable through either the original variable name or
the reference. For example, suppose we have the
following example
int a = 80;
int& b = i;
#include<iostream>
using namespace std;
main()
{ int a=80;
int& b=a; //b is alias varable
cout<<"value is"<<a;
cout<<" value of b"<<b;

You might also like