Sunday, 18 September 2016

PROGRAMS OF C++



  • PROGRAM TO FIND THE SIZE OF DATA TYPES.
  • PROGRAM BASED ON INCREMENT / DECREMENT OPERATORS.
  • PROGRAM BASED ON SWAPPING.
  • WRITE A PROGRAM TO FIND THE SUM OF TWO NUMBERS.
  • WRITE A PROGRAM TO REVERSE A NUMBER WITHOUT USING ANY CASE .
  • WRITE A PROGRAM TO MULTIPLY 2 FLOATING NUMBERS.
  • WRITE A PROGRAM TO PRINT "HELLO WORLD" IN DOUBLE QUOTES.
  • WRITE A PROGRAM TO FIND SMALLEST NUMBER WITHOUT USING ANY CASE.
  • WRITE A PROGRAM TO FIND THE FACTORIAL OF A NUMBER.
  • PROGRAM TO FIND THE PERIMETER AND AREA OF RECTANGLE.
  • WRITE A PROGRAM TO FIND THE MULTIPLICATION TABLE OF ANY NUMBER.
  • WRITE A PROGRAM TO DISPLAY THE FOLLOWING OUTPUT USING A SINGLE COUT STATEMENT.                                                                                                                       subject              marks                                                                                                                        mathematics=       86                                                                                                                          physics        =        96                                                                                                                         chemistry   =         98
  • WRITE A PROGRAM WHICH ACCEPT TEMPERATURE IN FAHRENHEIT AND PRINT IN CENTIGRADES. 
  • WRITE A PROGRAM TO FIND THE SIMPLE INTEREST.
  • WRITE A PROGRAM WHICH ACCEPTS A CHARACTER AND PRINTS ITS ASCII VALUE.
  • WRITE A PROGRAM TO CHECK WHEATHER THE GIVEN NUMBER IS POSITIVE OR NEGATIVE.



   
* WRITE A PROGRAM TO FIND THE SIZE OF DATA TYPES.


#include<iostream.h>
#include<conio.h>
    void main()
{
 int a;
 float b;
 char c; 
 double d;
 short e;

    cout<<"size of integer is %d= " <<sizeof(a);    //we use %d for integer
    cout<<"size of float is %f ="<<sizeof(b);         //we use %f for float 
    cout<<"size of character is %c = "<<sizeof(c); //we use %c for character
    cout<<"size of double is %f "<<sizeof(d);      //we use %f for double
    cout<<"size of short is %d="<<sizeof(e);        //we use %d for short

getch();

}
SAMPLE OUTPUT
SIZE OF INTEGER IS =2
SIZE OF FLOAT IS =4
SIZE OF CHARACTER IS=1
SIZE OF DOUBLE IS =8
SIZE OF SHORT IS =2

========================================================================


*WRITE  PROGRAMS TO SHOW INCREMENT OF A NUMBER .

CASE 1:

#include<iostream.h>
#include<conio.h>
void main();
{
   int i,j;
   i=5;
   j=++i;
   cout<<j;
   cout<<"\n"<<i;

getch();

}

CASE 2:

   #include<iostream.h>
   #include<conio.h>

    void main( )
{
   int i,j;
   i=5;
   j=i++;
  cout<<"\n"<<j;
  cout<<"\n"<<i;

getch();

CASE 3:

#include<iostream.h.
#include<conio.h>
   void main ()
{
  int i;
  i=5;
  i= ++i + ++i + i++;
  cout<<"\n"<<i;

getch();

}

CASE 4:

#include<iostream.h>
#include<conio.h>
 void main()
{
 int i;
 i=5;
 j=++i + i++ + ++i + i++;
 cout<<"\n"<<j;

 getch();

}

CASE 5:

#include<iostream.h>
#include<conio.h>
void main ()
{
 int i,j;
 i=2;
 j=5;
 i=j++ + --i + j-- + --i + i-- + j--;
 cout<<"\n"<<i;
 getch( );
}
========================================================================

*WRITE A PROGRAM TO SHOW SWAPPING OF NUMBERS.
  CASE 1:

#include<iostream.h>
#include<conio.h.
   void main ()
{
 int a,r;
 a=52;
 r=a/10;                   // value of a is divided by 10 
 cout<<"\n"<<r;
getch( )
}

CASE 2:

#include<iostream.h>
#include<conio.h>
 void main ()
{
  int n,s,r;                  //initialization
  n=123;
  s=0;
r=n%10
  n=n/10;                  //value of n is divided by 10
  s=s+r;       
  r=n%10;                // % symbol is called modulus it gives the remainder 
  s=s+r;
  n=n/10;
  s=s+n;
  cout<<"\n"<<s;   //this line represent the output  

getch();                 //getch means get the character which holds the screen and show the output

}
========================================================================

* WRITE A PROGRAM TO FIND THE SUM OF TWO NUMBERS .
#include<iostream.h>
#include<conio.h>
  void main ()
{
 int a, b, sum=0;     //initialization of variables
 cout<<"enter the value of a ";    //print statement 
 cin>>a;                                       //output statement 
 cout<<"enter the value of b ";
 cin>>b;
 sum=a+b;                                   //sum statement
 cout<<"\n sum is "<<sum;         //this line shows the sum of two numbers
getch();
}
=======================================================================
* WRITE A PROGRAM TO REVERSE NUMBER WITHOUT USING ANY CASE.
 #include<iostream.h>
# include<conio.h>
 void main ()
{
int n=521,s=0,r;
r=n%10;
  n=n/10;                  
  s=s*10+r 
  r=n%10;                
  s=s*10+r
  n=n/10   
  s=s*10+n;
getch();
}

SAMPLE OUTPUT
125
========================================================================

* WRITE A PROGRAM TO MULTIPLY TWO FLOATING NUMBERS

#include<iostream.h>
#include<conio.h.
 void main ()
{
double a,b,mul;
cout<<"\nenter the first number %f";
cin>>a;
cout<<"\n enter the second number%f";
cin>>b;
mul=a*b;
cout<<mul;
getch();
}

======================================================================= *WRITE A PROGRAM TO PRINT "HELLO WORLD IN DOUBLE QUOTES.

#include<iostream.h>
#include<conio.h>
void main ()
{
cout<<"\"hello world\"";
getch();
}

SAMPLE OUTPUT

"HELLO WORLD"
=======================================================================
*WRITE A PROGRAM TO FIND SMALLEST NUMBER WITHOUT USING ANY CASE.

#include<iostream.h>
#include<conio.h>

int compare(int a,int b)
{
return(a+4<b)? a:b;
}

  int main ()
{
  cout<<"\nsmallest number is :"<<compare(11,12);
  cout<<"\n"smallest number is :"<<compare(55,88);
  cout<<"\n"smallest number is :"<<compare(100,89);

getch();
return0;
}

SAMPLE OUTPUT

SMALLEST NUMBER IS 11
SMALLEST NUMBER IS 55
SMALLEST NUMBER IS 89
======================================================================= *WRITE A PROGRAM TO FIND THE FACTORIAL OF A NUMBER .

#include<iostream.h>
#include<conio.h>
int factorial(int var)
{
int fact=1;
for(int i=1;i<=var;i++)
fact=fact*i;
return fact;
}

  int main()
{
 cout<<"\nfactorial of a number is :"<<factorail(7);
 getch();
 return 0;
}

SAMPLE OUTPUT

FACTORIAL IS 5040.
 =======================================================================
* WRITE A PROGRAM TO FIND THE PERIMETER AND AREA OF A RECTANGLE.

#include<iostream.h>
#include<conio.h>

void main ()
{

clrscr();
int length,width ,perimeter ,area;        //Declaration
cout<<"length=\n";                             //prompt user
cin>>length;
cout<<"width=\n" ;
cin>>width;

perimeter=2*(length+width);            //formula to find the perimeter
area=length*width;                            //formula to find the area

cout<<endl;
       <<"perimeter is "<<perimeter;
cout<<endl;
       <<"area is "<<area;
        <<endl;
getch();
}
========================================================================
*WRITE A PROGRAM TO FIND THE MULTIPLICATION TABLE OF  A NUMBER.

#include<iostream.h>
#include<conio.h>
void main()
{
int n;
cout<<"enter the number";
cin>>n;
for(int  i=1;i<=10;i++)
{
cout<<n<<" * "<<i<<"="<<n*i<<endl;
}
getch();
}
========================================================================
*  WRITE A PROGRAM TO DISPLAY THE FOLLOWING OUTPUT USING A SINGLE COUT STATEMENT.                                                                                                                                   subject              marks                                                                                                                               mathematics       86                                                                                                                                    physics                96                                                                                                                                   chemistry            98
#include<iostream.h>
#include<conio.h>
void main ()
{
clrscr();
cout<<"subject"<<"\marks"<<"mathematics\n"<<86<<"physics\n"<<96<<"chemistry\n"<<98;
getch();
}

SAMPLE OUTPUT
SUBJECT                MARKS
MATHEMATICS     86
PHYSICS                  96 
CHEMISTRY             98
========================================================================
*WRITE A PROGRAM WHICH ACCEPT TEMPERATURE IN FAHRENHEIT AND PRINT IN CENTIGRADES.

#include<iostream.h>
#include<conio.h>
void main()
{
int f,c;
cout<<"enter the temperature in fahrenheit";
cin>>f;

c=5*(f-39)/9;                    //formula which is converting the temperature 

cout<<"temperature in celcius is ";
cin>>c;

getch();
}
========================================================================
*WRITE A PROGRAM TO FIND THE SIMPLE INTEREST.

#include<iostream.h>
#include<conio.h>
void main ()
{
int p,r,t,s;
cout<<"enter the principal ";      // user input
cin>>p;                                        //the values

cout<<"enter the rate ";
cin>>r;

cout<<"enter the time";
cin>>t;

s=(p*r*t)/100;       //formula to find the simple interest

cout<<"simple interest is "<<s;

getch();
}
========================================================================
*WRITE A PROGRAM WHICH ACCEPTS A CHARACTER AND PRINTS ITS ASCII VALUE

#include<iostream.h>
#include<conio.h>
int main ()                 //int means it returns a value otherwise it shows an error.
{

char ch;

cout<<"enter any character ";
cin>>ch;

cout<<"its ASCII value is" <<(int)ch;        

return 0;
getch();
}
========================================================================
*WRITE A PROGRAM TO CHECK WHEATHER THE GIVEN NUMBER IS POSITIVE OR NEGATIVE.

#include<iostream.h>
#include<conio.h>
void main()
{
int n;

cout<<"enter the number ";
cin>>a;

(a>0)?cout<<"the number is positive ":cout<<"the number is negative";  //using ternary operator

getch();
}
========================================================================


Saturday, 3 September 2016

characteristics of an array


  • ARRAY TERMINOLOGY
  • CHARACTERISTICS OF AN ARRAY 
 

                                               ARRAY TERMINOLOGY

SIZE : Number of elements or capacity to store elements in an array is called its size . It is always                    mentioned in brackets([ ]).


TYPE: Types refer to data type.It decides which type of element is stored in the array .It also instructs              the compiler to reserve memory according to data type .

BASE: The address of the first element (0th) is a base address . The array name itself stores address                of the first  element.

INDEX: The array name is used to refer to the array element. For example , num[x] , num is array                       name and x is index.The value of x begins from 0 to onwards depending on the size of the                   array .The index value is always an integer .

RANGE: Index of an array i.e value of x varies from lower bound to upper bound while writing or                     reading elements from an array . For example  in  num[100]  the range of index is 0 to 99.

WORD: It includes the space required for an element. in each memory location,computer can store a                  data piece.The space occupation varies from machine to machine.If the size of element is                     more than word (one byte) then it occupies two successive locations.The variables of data                    type  int,float,long need more than one byte in memory.

                                  CHARACTERISTICS OF AN ARRAY

  1. The declaration int a[5]  is nothing but creation of five variables of integer type in memory instead of declaring five variables for five values, the programmer can define them in an array .
  2. All the elements of an array share the same name,and they are distinguished from one another with the help of the element number.
  3. The element number in an array play a major role for calling each element.
  4. Any particular element of an array can be modified separately without disturbing the other elements.
                    int a[5]={1,2,3,4,8};
            If a programmer needs to replace  8 with 10,then it need not require changing all other                         numbers except 8.To carry out this task the statement  a[4]=10 can be used. Here,other four               elements are not disturbed.

      5. Any element of an array  a[ ]  can be assigned/equated to another ordinary variable or array                 variable of its type.
   

  EXAMPLE:
   
       b=a[2];
      a[2]=a[3];
  •   In the statement   b=a[2]  or vice versa,the value of a[2]  is asigned to 'b',where 'b' is an integer.
  • In the statement  a[2]=a[3]or vice versa ,the value of a[2] is assigned to  a[3],where both the elements are of the same array .
  • The array elements are stored in continuous memory locations.
     6. Array elements are stored in contigious memory locations.
 
     7. Once the arrays is declared,its lowest boundary cannot be changed but upper boundary can be               expanded .The array name itself is  a constant pointer and we cannot modify it.Therefor, the                 lowest boundary of an array cannot be expanded.In other words ,even if the boundary exceeds             then specified,nothing happens.the compiler throws no errors. 
     8. We know that an array name itself is a pointer . Though it is a pointer , it does not need '*'                    operator.The brackets([ ]) automatically denote that the variable is a pointer.
     9. All the elements of an array share the same name, and they are distinguished from one another            with the help of the element number.
   10. The amount of memory required for an array depends upon the data type and the number of                elements.The total size in bytes for a single dimensional array is computed as shown below:
               total bytes=sizeof(data type)  x size of array 
   11. The  operation such as insertion,deletion of an element can be done with the list  but cannot be            done with an array .Once an array is created we cannot remove or insert memory location. An              element can be deleted,replaced but the memory location as it is.

Friday, 2 September 2016

Initialization of Array

                              INITIALIZATION OF ARRAY 

The array initialization can be done as under:

int a[5]={1,2,3,4,5};

Here 5 elements are stored in an array 'a'. List of elements initialized is shown within the braces.The elements are stored sequentially in separate locations.Then the question arises how to call individually to each element from this bunch of integer elements.

Reading of element begins from '0'.By indicating the position of elements, one can retrieve element of an array.Array elements are called with array names.

a[0] refers to 1st element i.e 1.
a[1] refers to 2nd element i.e 2.
a[2] refers to 3rd element i.e 3.
a[3] refers to 4th element i.e 4.
a[4] refers to 5th element i.e 5.

EXAMPLE:

To store more than one value the programming languages have an built data structure called an array .

  1.  int num[5] ;
          In the above declaration.an integer array of five elements is declared .Memories for five                       integers,i.e. successive 10 bytes ,are reserved for the num array.To initialize the num array                   following syntax can be used.



      2. int num[5] = {1,2,4,2,5};

          In the above statement ,all elements are initialized .It is also possible to initialize individual                 element by specifying the subscript number in the square bracket following the array name.
          Array elements are accessed as follows:

              num[0]=1;
              num[1]=2;
              num[2]=4;
              num[3]=2;
              num[4]=5;

The initialization can be done at the compile time or dynamic at the run time .The above is an example of compile time initialization./

In the above array, the element num[0]  i.e 1 is the lowest bound and num[4] i.e 5 is the last element .In c and c++ ,there is no  bound checking .Hence the programmer has to check it while accessing or storing elements.Once   the array is declared , its lowest bound cannot be changed but the upper bound can be expanded.The array name itself is a constant pointe,and therefore we cannot modify it. Storing elements in contigious memory locations can expand the upper bound.  


The array name itself is a pointer .The array num  is pointer to the first element i.e  num cotains address of memory locations where element 1 is stored .The address stored in the array name is called the base address .



To access individual elements,the following syntax is used:

num[0] refers to the 1

num[1] refers to the 2


num[2] refers to the 4


num[3] refers to the 2


num[4] refers to the 5


Thus, an array is a colection of elements of the same data type ,stored in unique and successive memory location.



Monday, 29 August 2016

Introduction of Array


                                                 INTRODUCTION OF ARRAYS 

An array is a very popular and useful data structure used to store data elements in successive memory locations. More than one element is stored ia an sequence ,so it is also called a composite data structure.
An array is a linear and homogeneous data structure . An array permits homogeneous data.It means that similar types of elements are stored contiguously in the memory and that too under one variable name.It can be combined with a non-homogeneous structure, and a complex data structure can be created. We know that an array of structure objects can also be useful.An array can be declared of any standard or custom data type .The array of character (strings) type works somewhat differently from an array of integers,floating numbers.
Consider the following example .A variable A having data type integer is initially assigned some value and later on its value is changed .Later assigned value to the variable can be displayed.

void main ()
{
   int a=2;
    a=4;
   cout<<a;
}

OUTPUT =4
 
In the above example , the value of A printed is 4. 2 is assigned to A before assigning 4 to it .When we assign 4 to A then the value stored in A is replaced with the new value .Hence,ordinary variables are capable of storing one value at a time.This fact is the same for all the data types.This can be obtained with the help of arrays.
An array variable allows the storing of more similar data type element /values at a time .
Declaration of a one-dimensional array can be done with data type first, followed by the variable name and at least the size is enclosed in square brackets.
int a[5] ;
It tells the compiler that A is an integer type of an array and can store five integers.The compiler reserves 2 bytes of memory for each integer array element, i.e 10 bytes are reserved for storing five integers in the memory .
In the same way,an array of different data types is declared as follows:

char ch[10];
float real[10];
long num [5];
 When we declare a variable , for example:
int x;
 the variable x is declared and the memory locations of two bytes is allocated to them and later a single value can be stored in it.
x=4;
Every variable has a name ,a value its memory locations.Hence from the above we can say that only one value can be assigned /stored to a variable

  • An array is a group of contiguous or related data items that share a common name.
  • used when programs have to handle large amount of data 
  • each value is stored at a specific position 
  • position is called a index or superscript.Base index=0
  • The ability to use a single name to represent a collection of items and refer to an item by specifying the item number enables us to develop concise and efficient programs .For example ,a loop  with index as the control variable can be used to read the entire array , perform calculations, and print out the results.

Sunday, 14 August 2016

Looping in c++

A loop is defined as a block of statement ,which are execute for a certain no. of times in a repititive manner.the loops are of two type where,

  1. Definite loop =In which the block of statement are executive according to the counter control repitition .
  2. Indefinite loop= In which the program is executive in such a way where the total number of iteration cannot be calculated 

A sequence of statement is executed until a specified condition is true.This sequence of statement to be executed is kept inside the curly braces {} known as loop body.After every execution of loop body,condition is checked ,and if it is found to be true the loop body is executed again,  when condition check comes out to be false,the loop body will not be executed .

                                      THERE ARE THREE TYPES OF LOOPS IN C++


  1. WHILE LOOP
  2. DO-WHILE LOOP
  3. FOR LOOP
  4. NESTED FOR LOOPS
WHILE LOOP

The while loop is frequently used in programs for the repeated execution of statement in a loop .Until a certain  condition is satisfied the loops statement are executed ,while loop is also known as entry control loop,because it only execute the statement if the test condition is true ,so if the condition is false the compiler will not enter in the body of while loop and does not execute its statement.

SYNTAX:

{
Initialization of variable
while(condition)
{
body of while loop
increment/decrement counter
}
}

 EXAMPLE:

void main()
{
int x=1;
while(x<10)
{
cout<<"value is ":<<x;
x++;
}
}

                                                     DO-WHILE LOOP

The do -while loop is also known as exit control loop.,which me ans that the body of the loop is executing atleast once even if the test condition is false because the test condition is given at the ending of the loop.The test condition is tested for the next time to execute the loop .The basic
difference between while and do while is that while loop is executed only if the test condition is true whereas do-while executes atleast once as we check the test condition at the end which desire the re-entry (only if it is true)inside the loop.


SYNTAX:

void main()
{
initialization variable;
do
{
body ;
increment/decrement;
}
while(test condition)
}


EXAMPLE:

void main()
{
int x=1;
do
{
cout<<"value is :"<<x;
x++;
while(x<10)
}
getch();
}


                                                             FOR LOOP

FOR loop allow to execute a set of instructions until a certain conditions is  satisfied . Condition may be predefined or open-ended.The general syntax of the FOR loop will be as given below.

explanation:
the FOR statement contains three expressions which are separated by semicolons.Following actions are to be performed in the three expressions.

SYNTAX:
for(initialize counter;test condition ; re-evaluation parameter)
{
     statement 1;
     statement 2;
}




  1. The initialize counter sets to an initial value. This statement  is executed only once.
  2. The test condition is a relational expression that determines the number of iterations desired or determine when to exit from the loop . The FOR loop continuous to execute as long as conditional test is satisfied .When the condition becomes false the control of the loop program exists from the body of the  FOR  loop and executes next statement after the body of the loop.
  3. The re-evaluation parameter decided how to make changes in the loop (increment or decrement operations are to be used quite often).
  4. The body of the loop may contain either a single statement or multiple statement s.In case, there is only one statement after the FOR loop, braces may not be necessary .In such a case ,only one statement is executed till the condition is satisfied .It is good practice to use braces even for single statement following the for loops.
EXAMPLE :

   void main ()
{
  int i;

  clrscr ( );
 
  for(int i=1;i<=5;i++)

  cout<<"number: ",i,i*i);
}

                                                       NESTED FOR LOOPS

We can also use loop within loops ,In nested  FOR loops one or more FOR statements are included in the body of the loop . In other words c++ allows multiple FOR loops in nested forms.The numbers of iterations in this type of structure will be equal to the number of iteration in the outer loop multiplied by the number of iteration in the inner loop . Given below examples are based on the nested FOR loops.

EXAMPLE:

Write a program to perform subtraction of two loop variables.use nested for loop.

void main()
{
      ina a,b,sub;
     clrscr();
 
       for(a=3;a>=1;a--)
  {
        for(b=1;b<=2;b++)
     {
        sub=a-b;
       cout<<"a=%d a-b= %d"<<a,b,sub;
     }
  }

}


what is c++

                                                       WHAT IS C++

C++ is an object-oriented programming language . It was developed by Bjarne stroustrup at AT&T Bell Laboratories in murray hill , New jersey,USA in the early 1980's stroustrup ,an admirer of simula67 and a strong supporter of C, wanted to combine the best of both the languages and create a more powerful language that could support object-oriented programming features and still retain the power and elegance of c , The result was C++ . therefore,c++ is an extension of c with a major addition of the class construct feature of simula67,Since the class was a major addition to the original C language,'C with classes'However later in 1983,the name was changed to c++.The idea of c++ comes from the C increment operator ++, thereby suggesting that c++ is an augmented (incremented)version of c.

During the early 1990's the language underwent a number of improvements and changes.In November 1997, the ANSI/ISO standards committee standardised these changes and added several new features to the language specifications.

C++ is a superset of C, Most of what we already know about c applies to c++ also therefore, almost all C programs are also  c++ programs .However there are a few minor differences that will prevent a c program to run under c++ compiler, we shall see these differences later as and when they are encountered .

The most important facilities that c++  adds on to c are classes,inheritance,function overloading ,and operator overloading.These features enable creating of abstract data types,inherit properties from existing data types and support  polymorphism,thereby making c++ a truly object-oriented language.

The object-oriented features in c++ allow programmers to build large programs with clarity,extensibility and ease of maintenance,incorporating the spirit and efficiency of C. the addition of new features has transformed C from a language that currently facilitates top-down , structured design, to one that provides bottom-up,object oriented design.


                                               APPLICATION OF C+ +

C++ is a versatile language for handling very large programs.It is suitable for virtually any programming task including development of editors,compilers, databases,communication system and any complex real-life application system.

  • Since c++ allows us to create hierarchy -related objects ,We can build special object-oriented libraries which ca n be used later by many programmers.
  • While c++ is able tp map the real world problem property,the C part of C++ gives the language the ability to get close to the machine -level details.
  • C++ programs are easily maintainable and expandable .When a new feature needs to be implemented ,it is very easy to add to the existing structure of an object.
  • It is expected that C++ will replace C as a general-purpose language in the near future.


                                        A SIMPLE C++ PROGRAM

#include<iostream>          // include header file
using namespaces std ;
int main ()
{

cout<<"c++ is better than c"; // c++ statement
return 0;

}           // end of example 

Expressions and their types

                                          EXPRESSION AND THEIR TYPES

An expression is a combination of operators, constants and variables arranged as per the rules of the language.It may also include functions calls which return values.An expression may consist of one or more operands , and zero or more operators to produce a value. expressions may be of the following seven types.


  • Constant expressions 
  • Integral expressions 
  • Float expressions
  • pointer expressions
  • Relational expressions
  • Logical expressions
  • Bitwise expressions
An expression may also use combination of the above expression . Such expression are known as compound expressions.


CONSTANT EXPRESSIONS

CONSTANT expressions consist of only constant values. EXAMPLE:

15

20+5/2.0

'X'


INTEGRAL EXPRESSIONS 

integral expressions are those which produce integer results after implementing all the automatic and explicit type conversions . EXAMPLE :

m

m*n-5

m*'X'

5+ int(2.0)
where m and n are integer variables.

FLOAT EXPRESSIONS

Float expressions are those which,after all conversions, produce floating-point results.
EXAMPLE:

x+y

x*y /10

5 + float(10)

10.75

where x and y are floating-point variables.

POINTER EXPRESSIONS 

Pointer expressions produce address values.example:

&m

ptr

ptr +1

"xyz"
where x is a variable and ptr is a pointer.

RELATIONAL EXPRESSIONS 

Relational expressions yield results of type bool which takes a value true or false. Examples:

x<=y

a+b == c+d

m+n>100

When arithmetic expressions are used on either side of a relational operator,they will be evaluated first and then the results compared . Relational expressions are also known as BOOLEAN EXPRESSIONS .

LOGICAL EXPRESSIONS

Logical expressions combine two or more relational expressions and produces bool type results. Examples:

a>b &&x==10

x==10|| y==5

BITWISE EXPRESSIONS

Bitwise expressions are used to manipulate data at bit level.They are basically used for testing or shifting bits .Examples:

x<<3 // shift three bit position to left
y>>1 // shift one bit position to right

Shift operators are often used for multiplication and division by power of two.

ANSI c++ has introduced what are termed as operator keyword that can be used as alternative representation for operator symbols .