Sunday, June 28, 2015

Calculator using PHP and Css 3 ,html 5

Calculator Using PHP...

<title>Calculator</title>
<style>
span{
background-color: lightgreen;
border: 2px solid black;
textcolor: red;
}
div input{
    background-color: lightgrey;
    width: 320px;
    padding: 5px;
    border: 1px solid navy;
    margin: 25px;
}
div button{
    background-color: #FFFFF0;
    width: 360px;
    height: 40px;
    padding: 5px;
    border: 2px solid green;
 
}
div td{
    background-color:#FFEBFF;
    width: 200px;
    height: 10px;
    padding: 5px;
    border: 2px solid navy;
    }
div th{
    background-color: #FFD6D6;
    width: 200px;
    height: 10px;
    padding: 5px;
    border: 2px solid navy;
 
}
 p{
    background-color: #FFF5FF;
    width: 420px;
    height: 25px;
    padding: 5px;
    border: 3px solid black;

}
</style>


<form action=" " method="POST">
<div><table border=2"><tr><th color="red" width="59">
Value 1:<br><input type="text" name="a" ></th><th>
Value 2:<br><input type="text" name="b" ></th></tr><tr><td>
<input type="radio" name="s" value="+">Additon<br></td><td>
<input type="radio" name="s" value="-">Subtraction<br></td></tr><tr><td>
<input type="radio" name="s" value="*">Multiplication<br></td><td>
<input type="radio" name="s" value="/">Division<br></td></tr><tr><td>
<input type="radio" name="s" value="sin">Sin<br></td><td>
<input type="radio" name="s" value="cos">Cos<br></td></tr><tr><td>
<input type="radio" name="s" value="tan">Tan<br></td><td>
<input type="radio" name="s" value="decbin">Decimal to Binary<br></td></tr><tr><td>
<input type="radio" name="s" value="bindec">Binary to Decimal<br></td><td>
<input type="radio" name="s" value="dechex">Decimal to Hexa<br></td></tr><tr><td>
<input type="radio" name="s" value="hexdec">Hexa to Decimal<br></td><td>

</div>
<button value="Submit" name="submit" type="Submit">Submit</button></td></tr>
</form>

<tr>
<?php
$ans=0;
$a=$_POST['a'];
$b=$_POST['b'];
$q=$_POST['s'];
switch($q)
{
case "+":
$ans=$a+$b;
echo "Sum= ".$ans;
break;
case "-":
$sub=$a-$b;
echo "Sub= ".$sub;
break;
case "*":
$mul=$a*$b;
echo "Mul= ".$mul;
break;
case "/":
$div=$a / $b;
echo "DIV= ".$div;
break;
case cos:
 $ans = cos($a);
  break;
  case sin:
 $ans = sin($a);
  break;
  case tan:
 $ans = tan($a);
  break;
  case decbin:
 $ans = decbin($a);
  break;
  case bindec:
 $ans = bindec($a);
  break;
  case dechex:
 $ans = dechex($a);
  break;
  case hexdec:
 $ans = hexdec($a);
  break;
  case deg2rad:
 $and = deg2rad($a);
  break;
  case rad2deg:
 $ans = rad2deg($a);
  break;
}
echo "<p><i><b> Answer =<b><i> ".$ans."</p>";
//echo "<input type=/"text/" value='".$ans."'>";


?></tr></table>

<center><span>Copyright @ Programming SeekerzzZ </span></center>




Value 1:
Value 2:
AdditonSubtraction
MultiplicationDivision
SinCos
TanDecimal to Binary
Binary to DecimalDecimal to Hexa
Hexa to Decimal
Answer = ".$ans.""; ?>
Copyright @ Programming SeekerzzZ

Saturday, June 27, 2015

Thursday, June 25, 2015

Graph Adjacency Matrix using 2D-Array

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

void  main( )
 {
 int i, j ,siz;
 clrscr();
 int G[100][100];

cout<<" Enter the size of sequre Metrix  \n";
cout<<" Enter Rows siz :";
 cin>>i;
 cout<<" \n Enter Colums siz : "   ;
 cin>>j;
 siz=j;

 for(i=0 ; i < siz  ; i++)
 for(j=0 ; j< siz ; j++)
 {
 G[i][j]=0;
 }
 int a;
 cout<<" \n Enter the No of Edges: ";
 cin>>a;
 cout<<" \n Enter the exact location where  do you want  make edge  : "<<endl;
 for (int j1=1 ; j1 <= a ; j1++)
 {
 cout<<" Enter Row Number :";
 cin>>i;
 cout<<" Enter colum Number : ";
 cin>>j;
 G[i][j]=1;
 }
 cout<< " Adjancy Matrix ";
 for(i=0; i < siz; i++)
 {
 cout<< " \n ";
 for( j=0; j < siz ; j++)
 {
 cout<<"    "<< G[i][j];
 }
 cout<< " \n ";
 }
getch();
}




Graph Adjacency List using Link list

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

struct Adj_list
{

int dest;
struct Adj_list *next;

};
struct Adjlist
{
struct Adj_list *head;

};


class Graph
{
int v;
int i;
public:
struct Adjlist *array;

Graph(int v)
{
this->v=v;
array=new Adjlist[v];
array[i].head=NULL;
}

Adj_list *newAdj_list(int dest)
{

Adj_list *newnode =new Adj_list;
newnode->dest=dest;
newnode->next=NULL;
return newnode;
}



void addedge(int src,int dest)
{

Adj_list *newnode=newAdj_list(dest);

newnode->next=array[src].head;
array[src].head=newnode;
newnode=newAdj_list(src);
newnode->next=array[dest].head;
array[dest].head=newnode;
}

void display()
{

int i;
for(i=0; i< v; i++)
{
Adj_list *pcrawl=array[i].head;
cout<<" \n Adjancy List of vertex  "<<i<<" head";

while(pcrawl)
{
cout<<" -> "<<pcrawl->dest;
pcrawl=pcrawl->next;

}
cout<<endl;
}



}
};
void main()
{
clrscr();
Graph obj(5);
obj.addedge(0,1);
obj.addedge(0,4);
obj.addedge(1,2);
obj.addedge(1,3);
obj.addedge(1,4);
obj.addedge(2,3);
obj.addedge(3,4);

obj.display();
getch();
}

Saturday, June 13, 2015

Scan string using SCASB : Assembly code

include irvine32.inc

.data
source byte "my name is usman",0

msg1 byte "String to b compare : ",0


msg3 byte "Latter is Found : ",0
msg4 byte "Latter Not Found : ",0

.code
Main proc
call clrscr
call crlf
mov edx,offset msg1
call writestring
call crlf

call crlf
mov edx,offset source
call writestring
call crlf


;---------------------------

mov edi,offset source
mov al,'g'
mov ecx,lengthof source
cld
repne scasb
je L1
jne L2
;----------------------

L1:
call crlf
mov edx,offset msg3
call writestring
call crlf
jmp e

L2:
call crlf
mov edx,offset msg4
call writestring
call crlf
jmp e


e:
exit
main endp
end main

Compare string using CMPSB : Assembly Code

include irvine32.inc

.data
source byte "i my name is usman",0
dest   byte "i am not a khan....",0

msg1 byte "1st String: ",0
msg2 byte "2nd string: ",0

msg3 byte "String name Dest is Large : ",0
msg4 byte "String name Dest is Small : ",0
msg5 byte "String :both sorce & Dest are Equal : ",0

.code
Main proc
call clrscr
call crlf
mov edx,offset msg1
call writestring
call crlf

call crlf
mov edx,offset source
call writestring
call crlf

call crlf
mov edx,offset msg2
call writestring
call crlf

call crlf
mov edx,offset dest
call writestring
call crlf

mov esi,offset source
mov edi,offset dest
mov ecx,lengthof source
repe cmpsb
ja L1
jb L2
jmp L3

L1:
call crlf
mov edx,offset msg3
call writestring
call crlf
jmp e

L2:
call crlf
mov edx,offset msg4
call writestring
call crlf
jmp e

L3:
call crlf
mov edx,offset msg5
call writestring
call crlf
jmp e

e:
exit
main endp
end main


Copy using Movsb : Assembly Code

include irvine32.inc

.data
source byte "    my name is usman",0
dest   byte "    I am not a khan.",0
msg3 byte "After Copy: Copy source in dest String:  ",0
msg1 byte "String Named Source: ",0
msg2 byte "String Named Dest: ",0

.code
Main proc
call clrscr
call crlf
mov edx,offset msg1
call writestring
call crlf

call crlf
mov edx,offset source
call writestring
call crlf

call crlf
mov edx,offset msg2
call writestring
call crlf

call crlf
mov edx,offset dest
call writestring
call crlf
;-------------------------------
cld
mov esi,offset source
mov edi,offset dest
mov ecx,lengthof dest
rep movsb
;--------------------------------
call crlf
call crlf
mov edx,offset msg3
call writestring
call crlf

call crlf
mov edx,offset source
call writestring
call crlf

call crlf
mov edx,offset msg2
call writestring
call crlf

call crlf
mov edx,offset dest
call writestring
call crlf

exit
main endp
end main

Push & Pop in Assembly :: Stack

include irvine32.inc

.data

msg3 byte "Push character one by one in stack and moves ESP(32-bit-stack-pointer-register) downward:",0
msg byte "              Push: ",0
msg4 byte "Pop character one by one from stack and moves ESP(32-bit-stack-pointer-register) upward:",0
msg1 byte "              Pop: ",0
arr byte "usman siddique",0
asiz = ($-arr)-1
msg2 byte "---------------------------------------------------------------",0
msg5 byte "After perfoming the pop operation the name will print in reverse order.Now think about it, why it happens",0
msg6 byte "                      Name:  ",0
msg7 byte ".......................~~THE END~~.............................",0

.code
main proc
call clrscr
mov edx,offset msg3
call writestring
call crlf
mov ecx,asiz
mov esi,0

L1:
mov edx,offset msg
call writestring
movzx eax,arr[esi]
push eax ;PUSH:  In runtime stack ESP moves in downward direction instead of moving upward
                            ;but it does not matter what the  direction is,because stack follows LIFO structure in both(downward/upward) cases.
call writechar
call delay
call delay
call delay
call delay
call crlf
inc esi
loop L1

call crlf
mov edx,offset msg2
call writestring
call crlf
mov edx,offset msg4
call writestring
call crlf
mov ecx,asiz
mov esi,0
L2:
mov edx,offset msg1
call writestring
pop eax        ;POP:   In runtime stack ESP moves in upward direction instead of moving downward
                            ;but it does not matter what the direction is,because stack follows LIFO structure in both(downward/upward) cases.
mov arr[esi],al
call delay
call delay
call delay
call delay

call writechar
call crlf
inc esi
loop L2
call crlf
mov edx,offset msg5
call writestring
call crlf
call crlf
call crlf
call waitmsg ;show a msg: Press [Enter] to continue..
mov edx,offset msg6
call writestring
mov edx,offset arr
call writestring
call crlf
call crlf
call crlf
mov edx,offset msg7
call writestring
call crlf
call crlf
exit
main endp
end main

Str_Trim Function in Assembly

include irvine32.inc

.data
source byte "my name is usman and i am not A KHAN",0
msg   byte "After Invoking Str_trim function: ",0
msg1 byte "Lenght of source = ",0

.code
Main proc
call clrscr
call crlf
mov edx,offset msg1
call writestring
call crlf

call crlf
mov edx,offset source
call writestring
call crlf


call crlf
mov edx,offset msg
call writestring
call crlf


invoke str_trim , addr source , 'N'


call crlf
mov edx,offset source
call writestring

call crlf

exit
main endp
end main


Str_Length Function in Assembly

include irvine32.inc

.data
source byte "my name is usman and i am not A KHAN",0
msg   byte "After Iviking Str_Length function: ",0
msg1 byte "Lenght of source = ",0

.code
Main proc
call clrscr
call crlf
mov edx,offset msg1
call writestring
call crlf

call crlf
mov edx,offset source
call writestring
call crlf


call crlf
mov edx,offset msg
call writestring
call crlf


invoke str_length , addr source


call crlf
mov edx,offset msg1
call writestring
call writedec
call crlf

exit
main endp
end main

U_Case Function in Assembly

include irvine32.inc

.data
source byte "my name is usman and i am not A KHAN",0
msg   byte "After Iviking U-Case function: ",0
msg1 byte "String Source is = ",0

.code
Main proc
call clrscr
call crlf
mov edx,offset msg1
call writestring
call crlf

call crlf
mov edx,offset source
call writestring
call crlf


call crlf
mov edx,offset msg
call writestring
call crlf


invoke str_ucase , addr source


call crlf
mov edx,offset source
call writestring
call crlf

exit
main endp
end main

Str_Compare Function in Assembly

include irvine32.inc

.data
source byte "i  my name is usman",0
dest   byte "i am not a khan....",0

msg1 byte "1st String: ",0
msg2 byte "2nd string: ",0

msg3 byte "String name Dest is Large : ",0
msg4 byte "String name Dest is Small : ",0
msg5 byte "String :both sorce & Dest are Equal : ",0

.code
Main proc
call clrscr
call crlf
mov edx,offset msg1
call writestring
call crlf

call crlf
mov edx,offset source
call writestring
call crlf

call crlf
mov edx,offset msg2
call writestring
call crlf

call crlf
mov edx,offset dest
call writestring
call crlf

invoke str_compare , addr source ,addr dest
ja L1
jb L2
jmp L3

L1:
call crlf
mov edx,offset msg3
call writestring
call crlf
jmp e

L2:
call crlf
mov edx,offset msg4
call writestring
call crlf
jmp e

L3:
call crlf
mov edx,offset msg5
call writestring
call crlf
jmp e

e:
exit
main endp
end main

Str_Copy Function in Assembly

include irvine32.inc

.data
source byte "my name is usman",0
dest   byte "i am not a khan.",0

msg1 byte "1st String: ",0
msg2 byte "2nd string: ",0
msg3 byte "after Copy :: copy source string into dest : ",0

.code
Main proc
call clrscr
call crlf
mov edx,offset msg1
call writestring
call crlf

call crlf
mov edx,offset source
call writestring
call crlf

call crlf
mov edx,offset msg2
call writestring
call crlf

call crlf
mov edx,offset dest
call writestring
call crlf

call crlf
mov edx,offset msg3
call writestring
call crlf

invoke str_copy , addr source ,addr dest
;copy source string into dest

call crlf
mov edx,offset dest
call writestring
call crlf

exit
main endp
end main


Thursday, June 11, 2015

DFS tree in C++

#include<iostream.h>
#include<conio.h>
int cost[10][10],i,j,k,n;
int stack[10],top,v,visit[10],visited[10];
void main()
{
clrscr();
int m;
cout <<"Enter no of vertices\Nodes: ";
cin >> n;
cout <<"\nEnter no of Edges: ";
cin >> m;
cout <<"\n\tEnter All EDGES Source & Distination\n";
for(k=1;k<=m;k++)
{
cout<<"\nEnter Source: ";
cin >>i;
cout<<"\nEnter Distination: ";
cin>>j;
cost[i][j]=1;
cout<<"\n-----------------------\n";
}
cout <<"\nEnter initial vertex: ";
cin >>v;
cout <<"\nORDER OF VISITED VERTICES:\n";
cout <<v<<" ";
visited[v]=1;
k=1;
while(k<n)
{
for(j=n;j>=1;j--)
if(cost[v][j]!=0 && visited[j]!=1 && visit[j]!=1)
{
visit[j]=1;
stack[top]=j;
top++;
}
v=stack[--top];
cout<<v << " ";
k++;
visit[v]=0;
visited[v]=1;
}
getch();
}

Breadth First Search (BFS) in Graphs Algorithm Code in C++

#include<iostream.h>
#include<conio.h>
int cost[10][10],i,j,k,n;
int que[10],front,rare,v,visit[10],visited[10];
void main()
{
clrscr();
int m;
cout <<"Enter no of vertices\ Nodes: ";
cin >> n;
cout <<"\nEnter no of Edges: ";
cin >> m;
cout <<"\n\tEnter All EDGES by source & destination\n";
for(k=1;k<=m;k++)
{
cout<<"\nEnter Source: ";
cin >>i;
cout<<"\nEnter Destination: ";
cin>>j;
cost[i][j]=1;
cout<<"\n-----------------------\n";
}
cout <<"\nEnter initial vertex: ";
cin >>v;
cout <<"Visitied vertices:\n";
cout << v<<" ";
visited[v]=1;
k=1;
while(k<n)
{
for(j=1;j<=n;j++)
if(cost[v][j]!=0 && visited[j]!=1 && visit[j]!=1)
{
visit[j]=1;
que[rare++]=j;
}
v=que[front++];
cout<<v << " ";
k++;
visit[v]=0;
visited[v]=1;
}
getch();
}

Tuesday, June 9, 2015

HAng MaN Game in C++

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include <stdlib.h>
int a;
void main()
{

char ch[50],new1[50],word[50];
cout<<"              ------------------------------------------------"<<endl;
cout<<"                        Welcome To the HAng MaN Game "<<endl;
cout<<"              ------------------------------------------------"<<endl<<endl;
cout<<"                         |(((( Player OnE )))) | "<<endl<<endl ;
cout<<" HOW many character U Want to ENter == ";
cin>>a;
int g=11;

 ch[a],new1[a],word[a];
cout<<" \n \n";
cout<<"\n \n PLZ Insert Yr COmplete Words ==== ";

for(int b1=0;b1<a;b1++)
  { new1[b1]='_';

    cin>>ch[b1];
  }
f:
system("cls");

cout<<"                         ------------------------- \n ";
cout<<"                              PLayer Two  \n";
cout<<"                         ------------------------- \n\n ";
cout<<"                      ****************************** \n";
cout<<"                             GUess The characters  \n ";
cout<<"                      ****************************** \n \n \n";


cout<<"YOu have "<<g<<" tries Other wise your man will Hang \n\n";

cout<<"your Enter Charater Are === ";
for(int t=0;t<a;t++)
{
cout <<new1[t];
}
cout<<"\n";
if(g==10)
{
cout<<"                                                     /       "<<endl;
}
if(g==9)
{
cout<<"                                                     /       "<<endl;
cout<<"                                                    /        "<<endl;
}
if(g==8)
{
cout<<"                                                    __       "<<endl;
cout<<"                                              *-*-* /        "<<endl;
cout<<"                                                   /         "<<endl;
}
if(g==7)
{

cout<<"                                                    __        "<<endl;
cout<<"                                              *-*-* /         "<<endl;
cout<<"                                              ('_')/          "<<endl;
}
if(g==6)
{
cout<<"                                                    __        "<<endl;
cout<<"                                              *-*-* /         "<<endl;
cout<<"                                              ('_')/          "<<endl;
cout<<"                                                |             "<<endl;
}
if(g==5)
{

cout<<"                                                    __        "<<endl;
cout<<"                                              *-*-* /         "<<endl;
cout<<"                                              ('_')/          "<<endl;
cout<<"                                                |             "<<endl;
cout<<"                                                |             "<<endl;
}

if(g==4)
{
cout<<"                                                    __        "<<endl;
cout<<"                                              *-*-* /         "<<endl;
cout<<"                                              ('_')/          "<<endl;
cout<<"                                                |             "<<endl;
cout<<"                                               /|             "<<endl;


}
if(g==3)
{
cout<<"                                                    __        "<<endl;
cout<<"                                              *-*-* /         "<<endl;
cout<<"                                              ('_')/          "<<endl;
cout<<"                                                |             "<<endl;
cout<<"                                               /|\\           "<<endl;
}


if(g==2)
{
cout<<"                                                    __        "<<endl;
cout<<"                                              *-*-* /         "<<endl;
cout<<"                                              ('_')/          "<<endl;
cout<<"                                                |             "<<endl;
cout<<"                                               /|\\           "<<endl;
cout<<"                                                |             "<<endl;
}
if(g==1)
{
cout<<"                                                    __        "<<endl;
cout<<"                                              *-*-* /         "<<endl;
cout<<"                                              ('_')/          "<<endl;
cout<<"                                                |             "<<endl;
cout<<"                                               /|\\           "<<endl;
cout<<"                                                |             "<<endl;
cout<<"                                               / \\           "<<endl;

}
cout<<"\n\n";
cout<<" Enter charater ====" ;

int c,m=-1,l=0;
 for(int b=1;b<=a+a;b++)
 {
    cin>>word[b];
    for( c=0;c<a;c++)
      {
if(word[b]==ch[c])
{

new1[c]=word[b];

m=c;
}

       }
 if(m==-1)
g--;
 break;
 }


 for(int p=0;p<a;p++)
if(ch[p]==new1[p])
{
l++;
}
else
{ if(g>0)
 goto f;
system("cls");
cout<<"\n\n";
cout<<"                             -------------------         \n ";
cout<<"                             (((  You LOst ))))           \n ";
cout<<"                            -------------------         \n\n\n ";
cout<<"                                          __        "<<endl;
cout<<"                                    *-*-* /         "<<endl;
cout<<"                                    ('_')/          "<<endl;
cout<<"                                      |             "<<endl;
cout<<"                                     /|\\           "<<endl;
cout<<"                                      |             "<<endl;
cout<<"                                     / \\           "<<endl;

cout<<"Right Answer is ====== ";
for(int t=0;t<a;t++)
{
cout <<ch[t];
}
cout<<"\n\n\n\n\n";
}

if(l==a)
{
system("cls");

for(int t=0;t<a;t++)
{
cout <<new1[t];
}
cout<<"\n\n\n\n\n\n";
cout<<"                             -------------------         \n ";
cout<<"                              (((  You Won ))))           \n ";
cout<<"                            -------------------         \n\n\n\n\n ";

}
 getche();
}


Saturday, June 6, 2015

AVL Balance Tree in C++



AVL TREE IMPLEMENTAION:

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

struct avl_node
{
    int data;
    struct avl_node *left;
    struct avl_node *right;
}*root;

int max(int a,int b){
if (a>b){
return a;}
else { return b;
}
}

class avlTree
{
    public:

avlTree()
{
   root = NULL;
}


int height(avl_node *temp)
{
    int h = 0;
    if (temp != NULL)
    {
int l_height = height (temp->left);
int r_height = height (temp->right);
int max_height = max (l_height, r_height);
h = max_height + 1;
    }
    return h;
}

int diff(avl_node *temp)
{
    int l_height = height (temp->left);
    int r_height = height (temp->right);
    int b_factor= l_height - r_height;
    return b_factor;
}


avl_node* rr_rotation(avl_node *parent)
{
    avl_node *temp;
    temp = parent->right;
    parent->right = temp->left;
    temp->left = parent;
    return temp;
}

avl_node *ll_rotation(avl_node *parent)
{
    avl_node *temp;
    temp = parent->left;
    parent->left = temp->right;
    temp->right = parent;
    return temp;
}


avl_node* lr_rotation(avl_node *parent)
{
    avl_node *temp;
    temp = parent->left;
    parent->left = rr_rotation (temp);
    return ll_rotation (parent);
}


avl_node *rl_rotation(avl_node *parent)
{
    avl_node *temp;
    temp = parent->right;
    parent->right = ll_rotation (temp);
    return rr_rotation (parent);
}


avl_node* balance(avl_node *temp)
{
    int bal_factor = diff (temp);
    if (bal_factor > 1)
    {
if (diff (temp->left) > 0)
   temp = ll_rotation (temp);
else
   temp = lr_rotation (temp);
    }
    else if (bal_factor < -1)
    {
if (diff (temp->right) > 0)
   temp = rl_rotation (temp);
else
   temp = rr_rotation (temp);
    }
    return temp;
}


avl_node *insert(avl_node *root, int value)
{
    if (root == NULL)
    {
root = new avl_node;
root->data = value;
root->left = NULL;
root->right = NULL;
return root;
    }
    else if (value < root->data)
    {
root->left = insert(root->left, value);
root = balance (root);
    }
    else if (value >= root->data)
    {
root->right = insert(root->right, value);
root = balance (root);
    }
    return root;
}


void display(avl_node *ptr, int level)
{
    int i;
    if (ptr!=NULL)
    {
display(ptr->right, level + 1);
cout<<endl;
if (ptr == root)
cout<<"Root -> ";
for (i = 0; i < level && ptr != root; i++)
   cout<<"        ";
cout<<ptr->data;
display(ptr->left, level + 1);
    }
}


void inorder(avl_node *tree)
{
    if (tree == NULL)
        return;
    inorder (tree->left);
    cout<<tree->data<<"  ";
    inorder (tree->right);
}

void preorder(avl_node *tree)
{
    if (tree == NULL)
        return;
    cout<<tree->data<<"  ";
    preorder (tree->left);
    preorder (tree->right);

}


void postorder(avl_node *tree)
{
    if (tree == NULL)
        return;
    postorder ( tree ->left );
    postorder ( tree ->right );
    cout<<tree->data<<"  ";
}

};


void main()
{
    int choice, item;
    avlTree avl;
    clrscr();
    while (1)
    {
cout<<"\n\n-----------------------------------\n"<<endl;
cout<<"              AVL Tree Implementation    "<<endl;
cout<<"\n---------------------------------------\n"<<endl;
cout<<"[ 1. Insert Element into the tree]"<<endl;
cout<<"[ 2. Display Balanced AVL Tree   ]"<<endl;
cout<<"[ 3. InOrder traversal           ]"<<endl;
cout<<"[ 4. PreOrder traversal          ]"<<endl;
cout<<"[ 5. PostOrder traversal         ]"<<endl;
cout<<"[ 6. Exit                        ]"<<endl<<endl;
cout<<"[ Enter your Choice:. . . .:     ";
cin>>choice;
cout<<"\n\n--------------------------------------\n\n";
switch(choice)
{
case 1:
   cout<<"\nHow Many Node You want to insert: ";
   cin>>choice;
   for(int x=0;x<=choice;x++){
   cout<<"\nEnter value to be inserted: ";
   cin>>item;
   root = avl.insert(root, item);}
   break;
case 2:
   if (root == NULL)
   {
cout<<"\nTree is Empty\n"<<endl;
continue;
   }
   cout<<"\nBalanced AVL Tree:"<<endl;
   avl.display(root, 1);
   break;
case 3:
   cout<<"\nInorder Traversal:"<<endl;
   avl.inorder(root);
   cout<<endl;
   break;
case 4:
   cout<<"\nPreorder Traversal:"<<endl;
   avl.preorder(root);
   cout<<endl;
   break;
case 5:
   cout<<"\nPostorder Traversal:"<<endl;
   avl.postorder(root);
   cout<<endl;
   break;
case 6:
   exit(1);
   break;
default:
   cout<<"\nWrong Choice\n"<<endl;
}
    }


    }