C++
LANGUAGE
§ It is an extension Language of c
§ Object Oriented Programing Lanuguage(OOPs)
§
Author :
Bjarne Stroustrup – 1980 – AT & T
§
Languages Used – 1. C Language (Low level Features)
o
2. Simula67(Class concept)
Characteristics of OOPs
Ø Class
Ø Encapsulation
Ø Polymorphism
Ø Inheritance
Ø Overloading
Program Structure
#include
Directive
Global
Declaration;
void main()
{
Local Declaration;
}
Functions;
Data
Types
·
User
Defined Type
·
Buil-in-Type
·
Derived
Type
User Defined Type
·
Structure
·
·
Class
·
Enumeration
Built-in-Type
·
Integral
Type – int, char
·
Void
·
Floating
Type – float, double
Derived Type
·
Array
·
Function
·
Pointer
·
Reference
DATA TYPE
·
int – 2 byte
·
char – 1 byte
·
float – 4 byte
·
double
– 8 byte (double precision floating point)
·
long
int – 4 byte – more digits
·
short
int – 2 byte – fewer digits
·
unsigned
char – 1 byte
·
unsigned
int – 2 byte
·
long
double – 10 byte(double precision floating point)
Operators
Arithmetic
Operator
+ addition
- subtraction
* multiplication
/ division
% modulus
Relational Operators
> greater
than
< less than
>= greater than
<= less than
= = equal to
!= not equal to
Arithmetic Assignment operators
= simple assignment
+= assign sum
-= assign difference
*= assign product
/= assign quotient
%= assign remainder
Logical operators
&& and operator
|| or operator
! not operator
Increment and Decrement operator
++<id> prefix increment
<id>++ postfix increment
- - <id> prefix decrement
<id> - - postfix decrement
Bitwise Logical Operators
& bitwise AND
|| bitwise OR
^ bitwise exclusive OR
<< left shift
>> right shift
For statement
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i;
cout<<"Enter the
value=";
for(i=1;i<=5;i++)
{
cout<<i<<endl;
getch();
}
}
While statement
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i;
while(i<=5)
{
cout<<i<<endl;
i++;
getch();
}
}
Do while statement
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int i=1;
do
{
cout<<i<<endl;
i++;
}
while(i<=5);
getch();
}

No comments:
Post a Comment