Wednesday, 2 August 2017

Postfix expression evaluation like: xy+

Problem Statement:
Postfix expression evaluation like: xy+     (x=100, y=200) i:e 100200+

//Program By : Mr. Nitin M Shivale 9096454130 if any suggestion please!!!!
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
#include<iostream.h>
#include<conio.h>
//declaration of class for postfix expression evaluation.
class stack
{
 int top;           //by default private (data memebers)
 int stk[20];
 char inp[20];
 int x,i;
 public:
 stack()     //constructor to init data members
 {
  top=-1;
  x=i=0;
 }
 void getdata();    //memeber functions..
 void show();
 int isempty();
 int isfull();
 void push(int);
 int pop();
 int posteval();
}; // end of class stack declaration.
/*************************************************
Fun name: posteval()
return type:integer
no of arg:NULL
purpose: To eval postfix expression.
**************************************************/

int stack::posteval()
{
 int t1,t2,t3;
 for(i=0;inp[i]!='\0';i++)
 {
  if(isalpha(inp[i]))  //to check whether operand or operator.
  {
   cout<<"\nEnter the value of "<<inp[i];
   cin>>x;
   push(x);    //if operand push it into stack.
  }
  else
  {
   t1=pop();  //if operator pop 2 operand from stack.
   t2=pop();
   switch(inp[i])  //as per the operator switch into case & perform operation
   {
    case '+':t3=t1+t2;
         push(t3);
         break;
    case '-':t3=t1-t2;
         push(t3);
         break;
    case '*':t3=t1*t2;
         push(t3);
         break;
    case '/':t3=t1/t2;
         push(t3);
         break;
   }//end of switch
  }//end of else
 }//end of for loop
 return pop(); //after evaluation return the final result
}

int stack::pop() //To return the stack value.
{
 int z;
 z=stk[top];
 top--;
 return z;
}

int stack::isempty()  //To check the stack empty case
{
 if(top==-1)
  return 0;
 else
  return 1;
}

void stack::push(int n) //push the value inside the stack.
{
 top++;
 stk[top]=n;
}
void stack::getdata()   //To accept the postfix expression from user.
{
 cout<<"\nEnter the expression:";
 cin>>inp;
}
int stack::isfull() //To check stack full condition.
{
 if(top==20)
  return 1;
 else
  return 0;
}

void stack::show()//To display the postfix expression
{
 cout<<"\n Postfix Expression Evaluation are as follows...";
 while(inp[i]!='\0')
 {
  cout<<inp[i];
  i++;
 }
}
int main()  //Program execution starts from here
{
 int res;
 cout<<"\nPostfix Evaluation....!!!";
 stack s1;      //objecct creation
 s1.getdata();
 s1.show();   //member function calling.
 res=s1.posteval();
 cout<<"\nThe final result of exp is:"<<res;
 getch();
 return 0;
}

Thursday, 22 September 2016

C++ program for simulating job queue.

Group D: (Assignment No:01) (SPPU Syllabus Asignment No:28)

Problem Statement:

Queues are frequently used in computer programming, and a typical example is the creation of a job queue by an operating system. If the operating system does not use priorities, then the jobs are processed in the order they enter the system. Write C++ program for simulating job queue. Write functions to add job and delete job from queue.



Program Code:

//========================================
// Name        : priosimpq.cpp
// Author      : Nitin Shivale
// Version     : 1
// Copyright   : Your copyright notice
// Description : Operating System simple job queue and priority job queue in C++, Ansi-style
//================================================

#include <iostream>
using namespace std;
#define size 5

class spq
{
    int f,r,job,djob;            //data members
    int simpq[size],prioq[size];
public:
    spq() //Default constructor
    {
     f=r=-1; //init front and rear to -1.
     job=djob=0;
     prioq[-1]=0;
    }
    //To check Q is full or not
    int isQfull()
    {
        if(r==size-1)
            return 1;
        else
            return 0;
    }
    //To check Q is empty or not
    int isQempty()
    {
        if((f==-1)||(f>r))
            return 1;
        else
            return 0;
    }
    void simpqadd(); //member functions.
    void showsimpleQ();
    void delsimpleQ();
    void prioqadd();
    void delprioQ();
    void showprioQ();
};

//To insert the job inside the simple queue.
void spq::simpqadd()
{
    cout<<"\nEnter the Job: ";
    cin>>job;
    if(isQfull())
        cout<<"\nSorry !! Queue is full....\n";
    else
    {
        if(f==-1)
        {
            f=r=0;
            simpq[r]=job;
        }
        else
        {
            r=r+1;
            simpq[r]=job;
        }
    }

}

//To delete job from the simple queue.
void spq::delsimpleQ()
{
    if(isQempty())
        cout<<"\nSorry Q is empty...\n";
    else
    {
        djob=simpq[f];
        f=f+1;
        cout<<"\nDeleted job is: "<<djob;
    }
}

//To show all the jobs from SimpleQueue.
void spq::showsimpleQ()
{
    cout<<"\nThe simple Queue job are as follows....\n";
    int temp;
    for(temp=f;temp<=r;temp++)
    {
        cout<<"\t"<<simpq[temp];
    }
}

//To delete job from the simple queue.
void spq::delprioQ()
{
    if(isQempty())
        cout<<"\nSorry Q is empty...\n";
    else
    {
        djob=prioq[f];
        f=f+1;
        cout<<"\nDeleted job is: "<<djob;
    }
}

//To show all the jobs from PrioQueue.
void spq::showprioQ()
{
    cout<<"\nThe priority Queue job are as follows....\n";
    int temp;
    for(temp=f;temp<=r;temp++)
    {
        cout<<"\t"<<prioq[temp];
    }
}

//To add the jobs as per the priority.
void spq::prioqadd()
{
    int t=0;
    cout<<"\nEnter the job: ";
    cin>>job;
    if(isQfull())
        cout<<"\nSorry!! Priority Queue is full...\n";
    else
    {
        if(f==-1)
        {
            f=r=0; //initially when q is empty insert first job.
            prioq[r]=job;
        }
        else if(job<prioq[r]) //Check the priority(Ascending) of incoming job if it is high
        {
         t=r;
         while(job<prioq[t])//do until priority is high
         {
            prioq[t+1]=prioq[t]; //then shift all the jobs towards right
            t=t-1; //decrement index to check another job.
         }
         t=t+1; //increment index
         prioq[t]=job; //store job at its appropriate location.
         r=r+1; //increment rear index by one
        }
        else
        {
            r=r+1; // as per the priority store in Q.
            prioq[r]=job;
        }
    }
}

int main()
{
    spq s1,s2; //object creation. s1 for simple Q and s2 for priority Q
    int ch;
    do
    {
     cout<< "\n\t!!!Operating System Job Queue!!!" << endl; // prints the msg.
     cout<<"\n1.SimpleQ Add_Job\n2.SimpleQ Del_Job\n3.Show SimpleQ\n4.PrioQ Add_Job\n5.PrioQ Del_Job\n6.Show PrioQ";
     cout<<"\nEnter Your Choice:";
     cin>>ch;
     switch(ch)
     {
      case 1:s1.simpqadd();break;//calling adding element in simple Q without priority.
      case 2:s1.delsimpleQ();break;
      case 3:s1.showsimpleQ();break;
      case 4:s2.prioqadd();break;//calling adding element in priority Q with priority.
      case 5:s2.delprioQ();break;
      case 6:s2.showprioQ();break;
     }
    }while(ch!=7);
    return 0;
}
/************************** OUTPUT ***********************************


    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:1

Enter the Job: 10

    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:1

Enter the Job: 20

    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:1

Enter the Job: 15

    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:1

Enter the Job: 5

    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:1

Enter the Job: 6

    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:1

Enter the Job: 2

Sorry !! Queue is full....

    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:3

The simple Queue job are as follows....
    10    20    15    5    6
    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:4

Enter the job: 10

    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:6

The priority Queue job are as follows....
    10
    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:4

Enter the job: 20

    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:6

The priority Queue job are as follows....
    10    20
    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:4

Enter the job: 15

    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:6

The priority Queue job are as follows....
    10    15    20
    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:4

Enter the job: 5

    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:6

The priority Queue job are as follows....
    5    10    15    20
    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:4

Enter the job: 6

    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:6

The priority Queue job are as follows....
    5    6    10    15    20
    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:5

Deleted job is: 5
    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:6

The priority Queue job are as follows....
    6    10    15    20
    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:5

Deleted job is: 6
    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:6

The priority Queue job are as follows....
    10    15    20
    !!!Operating System Job Queue!!!

1.SimpleQ Add_Job
2.SimpleQ Del_Job
3.Show SimpleQ
4.PrioQ Add_Job
5.PrioQ Del_Job
6.Show PrioQ
Enter Your Choice:
 **************************************************************************/

Monday, 19 September 2016

Pizza parlor accepting maximum M orders.

Group D : (Assignment No: 02) (SPPU Syllabus Assignmnet No: 31)

Problem Statement:
Pizza parlor accepting maximum M orders. Orders are served in first come first served basis. Order once placed cannot be cancelled. Write C++ program to simulate the system using circular queue using array.

Program Code:

//==============================================
// Name        : Pizza_parlor.cpp
// Author      : Nitin Shivale
// Version     : 1.
// Copyright   : Your copyright notice
// Description : ervedPizza parlor accepting maximum M orders.
//==============================================

#include <iostream>
using namespace std;
#define size 5
class pizza
{
    int porder[size];
    int front,rear;
public:
    pizza()
    {
     front=rear=-1;
    }
    int qfull()
    {
     if((front==0)&&(rear==(size-1))||(front==(rear+1)%size))
         return 1;
     else
         return 0;
    }
    int qempty()
    {
        if(front==-1)
            return 1;
        else
            return 0;
    }
    void accept_order(int);
    void make_payment(int);
    void order_in_queue();
};
void pizza::accept_order(int item)
{
    if(qfull())
        cout<<"\nVery Sorry !!!! No more orders....\n";
    else
    {
        if(front==-1)
        {
            front=rear=0;
        }
        else
        {
            rear=(rear+1)%size;
        }
        porder[rear]=item;
    }
}

void pizza::make_payment(int n)
{
    int item;
    char ans;
    if(qempty())
        cout<<"\nSorry !!! order is not there...\n";
    else
    {
      cout<<"\nDeliverd orders as follows...\n";
      for(int i=0;i<n;i++)
      {
          item=porder[front];
          if(front==rear)
          {
               front=rear=-1;
          }
          else
          {
              front=(front+1)%size;
          }
          cout<<"\t"<<item;
      }
      cout<<"\nTotal amount to pay : "<<n*100;
      cout<<"\nThank you visit Again....\n";
    }
}

void pizza::order_in_queue()
{
    int temp;
    if(qempty())
    {
        cout<<"\nSorry !! There is no pending order...\n";
    }
    else
    {
        temp=front;
        cout<<"\nPending Order as follows..\n";
        while(temp!=rear)
        {
            cout<<"\t"<<porder[temp];
            temp=(temp+1)%size;
        }
        cout<<"\t"<<porder[temp];
    }
}
int main()
{
    pizza p1;
    int ch,k,n;
    do
    {
     cout<<"\n\t***** Welcome To Pizza Parlor *******\n";
     cout << "\n1.Accept order\n2.Make_payment\n3.Pending Orders\nEnter u r choice: ";
     cin>>ch;
     switch(ch)
     {
      case 1:cout<<"\nWhich Pizza do u like most....\n";
             cout<<"\n1.Veg Soya Pizza\n2.Veg butter Pizza\n3.Egg_Pizza";
             cout<<"\nPlease enter u r order: ";
             cin>>k;
             p1.accept_order(k);
             break;
      case 2:cout<<"\nHow many Pizza ?";
             cin>>n;
             p1.make_payment(n);
             break;
      case 3:cout<<"\n Following orders are in queue to deliver....as follows..\n";
             p1.order_in_queue();
             break;
     }
    }while(ch!=4);

    return 0;
}
/******************* OUTPUT *********************************************************

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 1

Which Pizza do u like most....

1.Veg Soya Pizza
2.Veg butter Pizza
3.Egg_Pizza
Please enter u r order: 2

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 1

Which Pizza do u like most....

1.Veg Soya Pizza
2.Veg butter Pizza
3.Egg_Pizza
Please enter u r order: 3

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 1

Which Pizza do u like most....

1.Veg Soya Pizza
2.Veg butter Pizza
3.Egg_Pizza
Please enter u r order: 2

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 1

Which Pizza do u like most....

1.Veg Soya Pizza
2.Veg butter Pizza
3.Egg_Pizza
Please enter u r order: 3

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 3

 Following orders are in queue to deliver....as follows..

Pending Order as follows..
    2    3    2    3
    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 1

Which Pizza do u like most....

1.Veg Soya Pizza
2.Veg butter Pizza
3.Egg_Pizza
Please enter u r order: 1

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 3

 Following orders are in queue to deliver....as follows..

Pending Order as follows..
    2    3    2    3    1
    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 1

Which Pizza do u like most....

1.Veg Soya Pizza
2.Veg butter Pizza
3.Egg_Pizza
Please enter u r order: 2

Very Sorry !!!! No more orders....

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 2

How many Pizza ?2

Deliverd orders as follows...
    2    3
Total amount to pay : 200
Thank you visit Again....

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 3

 Following orders are in queue to deliver....as follows..

Pending Order as follows..
    2    3    1
    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 2

How many Pizza ?3

Deliverd orders as follows...
    2    3    1
Total amount to pay : 300
Thank you visit Again....

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 3

 Following orders are in queue to deliver....as follows..

Sorry !! There is no pending order...

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 1

Which Pizza do u like most....

1.Veg Soya Pizza
2.Veg butter Pizza
3.Egg_Pizza
Please enter u r order: 1

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 1

Which Pizza do u like most....

1.Veg Soya Pizza
2.Veg butter Pizza
3.Egg_Pizza
Please enter u r order: 2

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 1

Which Pizza do u like most....

1.Veg Soya Pizza
2.Veg butter Pizza
3.Egg_Pizza
Please enter u r order: 3

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 1

Which Pizza do u like most....

1.Veg Soya Pizza
2.Veg butter Pizza
3.Egg_Pizza
Please enter u r order: 1

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 1

Which Pizza do u like most....

1.Veg Soya Pizza
2.Veg butter Pizza
3.Egg_Pizza
Please enter u r order: 2

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 1

Which Pizza do u like most....

1.Veg Soya Pizza
2.Veg butter Pizza
3.Egg_Pizza
Please enter u r order: 3

Very Sorry !!!! No more orders....

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 3

 Following orders are in queue to deliver....as follows..

Pending Order as follows..
    1    2    3    1    2
    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 2

How many Pizza ?2

Deliverd orders as follows...
    1    2
Total amount to pay : 200
Thank you visit Again....

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 3

 Following orders are in queue to deliver....as follows..

Pending Order as follows..
    3    1    2
    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 1

Which Pizza do u like most....

1.Veg Soya Pizza
2.Veg butter Pizza
3.Egg_Pizza
Please enter u r order: 1

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 3

 Following orders are in queue to deliver....as follows..

Pending Order as follows..
    3    1    2    1
    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 1

Which Pizza do u like most....

1.Veg Soya Pizza
2.Veg butter Pizza
3.Egg_Pizza
Please enter u r order: 2

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 3

 Following orders are in queue to deliver....as follows..

Pending Order as follows..
    3    1    2    1    2
    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice: 1

Which Pizza do u like most....

1.Veg Soya Pizza
2.Veg butter Pizza
3.Egg_Pizza
Please enter u r order: 1

Very Sorry !!!! No more orders....

    ***** Welcome To Pizza Parlor *******

1.Accept order
2.Make_payment
3.Pending Orders
Enter u r choice:

 *******************************************************/

Sunday, 18 September 2016

Infix to Postfix conversion code in c++

Group C: (Assignment No: 02) (SPPU Syllabus Assignment No: 25)
Problem Statement:
Implement C++ program for expression conversion as infix to postfix and its evaluation using stack based on given conditions
i. Operands and operator, both must be single character.
ii. Input Postfix expression must be in a desired format.
iii. Only '+', '-', '*' and '/ ' operators are expected.

Program Code:

//================================================================================================================================
// Name        : infix_postfix.cpp
// Author      : Nitin Shivale
// Version     : 1
// Copyright   : Your copyright notice
// Description : Conversion of infix expression to postfix expression and evaluation of postfix expression using stack, Ansi-style
//================================================================================================================================

#include <iostream>
#include<ctype.h>
using namespace std;
//class inpo containing data member and member functions
class inpo
{
    char in[20],po[20],stk[10];//stack for expression conversion.
    int i,j,is,ic,top,top1; //Two top one for stack and one for stack 1.
    int stk1[10]; //Stack 1 for expression evaluation.
public:
    inpo()
    {
     i=j=is=ic=0; //initialization of data members
     top=top1=-1;
    }
    bool IsOperand(char C)
    {
        if(C >= '0' && C <= '9') return true;
        if(C >= 'a' && C <= 'z') return true;
        if(C >= 'A' && C <= 'Z') return true;
        return false;
    }
    void getinfix() //Accept the infix expression
    {
        cout<<"\nEnter valid infix Expression: ";
        cin>>in; //Stored infix exp in in[]char array.
    }
    void showinfix() //Show the infix expression
    {
        cout<<"\t"<<in;
    }
    int isempty() //Stack basic functions.
    {
        if(top==-1)
            return 1;
        else
            return 0;
    }
    int isfull()
    {
        if(top==9)
            return 1;
        else
            return 0;
    }
    void push1(int x1)//for integer stack
    {
        top=top+1;
        stk1[top]=x1;
    }
    int pop1() //for integer stack
    {
       int s1;
       s1=stk1[top];
       top=top-1;
       return s1;
    }
    void push(char x)//for character stack
    {
        top=top+1;
        stk[top]=x;
    }
    char pop()//for character stack
    {
        char s;
        s=stk[top];
        top=top-1;
        return s;
    }
    void showpostfix()
    {
        cout<<"\t"<<po;
    }
    void convert();
    int instackprio();
    int incomingprio(char); //member functions
    void postfixExpEval();
};
void inpo::postfixExpEval() //To evaluate the postfix expression
{
    i=0;
    char ch;
    int op1,op2,res,tot;
        while(po[i]!='\0')//read postfix expression one by one
        {
            ch=po[i];
            if((ch=='+')||(ch=='-')||(ch=='*')||(ch=='/')||(ch=='^')) //isdigit(ch) built in function to check digit.
            {
                switch(ch)//if operator pop and perform operation and push back into the stack.
                {
                case '+':op2=pop1();
                         op1=pop1();
                         res=op1+op2;
                         push1(res);
                         break;
                case '-':op2=pop1();
                         op1=pop1();
                         res=op1-op2;
                         push1(res);
                         break;
                case '*':op2=pop1();
                         op1=pop1();
                         res=op1*op2;
                         push1(res);
                         break;
                case '/':op2=pop1();
                         op1=pop1();
                         res=op1/op2;
                         push1(res);
                         break;
                case '^':op2=pop1();
                         op1=pop1();
                         res=op1;
                         while(op2>1)
                         {
                          res=res*op1;
                          op2--;
                         }
                         push1(res);
                         break;
                }//end of switch

            } //end of if
            else if(IsOperand(ch))//To check operand we use IsOperand function.
            {
                push1(ch-'0'); //if operand push it inside stack
            } //end of else
            i=i+1;
        }//end of while

    tot=pop1(); //final evaluated result at the top of stack.
    cout<<"\nResult is:"<<tot;
}//end of fun

/*******************************************************************
 * Function Name: To convert infix expression to postfix expression.
 * return type: Void
 *******************************************************************/

void inpo::convert()
{
    i=j=0;
    char p,k;
    while(in[i]!='\0')//do until null character not found
    {
     p=in[i];//to read one by one from infix expression
     if((p=='(')||(p=='+')||(p=='-')||(p=='*')||(p=='/')||(p=='^')||(p==')'))
     {
         if(isempty()) //here we are dealing with operator only as per their priority.
         {
             push(p); //if initially stack is empty push
         }
         else if(p==')') //when we encountered with ')' bracket pop from stack until we r not encountered with '(' bracket.
         {
             k=pop();
             while(k!='(') //check the pop element with '(' bracket. if equal stop poping.
             {
                 po[j]=k; //pop and store it inside the postfix expression array po[].
                 j++;     //increment po[] array index by 1.
                 k=pop(); //pop next element
             }
         }
         else
         {
             is=instackprio(); //when we are pushing the operator inside the stack.
             ic=incomingprio(p);// we are always checking their incoming and instack priority.
             if(is>ic)//if instack priority is gretter than incoming priority
             {
              k=pop(); //pop the stack top operator whose priority is bigger than incoming operator from stack.
              po[j]=k;//store it in postfix expression array po[j]
              j++;  //increment j by one.
              push(p);//then push the incoming operator in stack.
             }
             else
             {
                 push(p); //if incoming operator priority is gretter than instack operator priority then
             }            // directly push the incoming operator inside the stack.
         }
     }
     else// if opearnd is their directly store it inside the postfix expression array po[j].
     {
        po[j]=p;
        j++; //increment j by one.
     }
     i=i+1; //read the next character of infix expression for conversion.
    }//end of while loop
    if(in[i]=='\0')//if we encountered with NULL Character of infix expression then
    {
        while(!isempty())//pop the stack containts until stack is not empty and
        {
         k=pop(); //pop from stack
         po[j]=k; //store it inside the postfix expression array po[j].
         j++;  //increment j by one.
        }
    }
 po[j]='\0'; // at the end of the postfix expression store null character to indicate end of the expression.
}

/* * Function to check the instack priority of operator * */
int inpo::instackprio()
{
    char b;
    b=stk[top];
    switch(b)
    {
     case '(':return 0; break;
     case '+':return 2; break;
     case '-':return 2; break;
     case '*':return 4; break;
     case '/':return 4; break;
     case '^':return 5; break;
    }
}
/* * Function to check the priority of incoming operator * */
int inpo::incomingprio(char ch)
{
    switch(ch)
    {
     case '(':return 9; break;
     case '+':return 1; break;
     case '-':return 1; break;
     case '*':return 3; break;
     case '/':return 3; break;
     case '^':return 6; break;
    }
}

int main()
{
    inpo p1;
    p1.getinfix();
    p1.showinfix();
    cout<<"\nAfter conversion from infix to postfix...\n";
    p1.convert();
    p1.showpostfix();
    cout << "\n\n!!!POSTFIX EXPRESSION EVALUATION ARE AS FOLLOWS..!!!" << endl;
    p1.postfixExpEval();
    return 0;
}

/************** OUTPUT***********************************************************
 *
 Enter valid infix Expression: 2^4
    2^4
After conversion from infix to postfix...
    24^

!!!POSTFIX EXPRESSION EVALUATION ARE AS FOLLOWS..!!!

Result is:16

Enter valid infix Expression: (9-1)/(4-2)^2
    (9-1)/(4-2)^2
After conversion from infix to postfix...
    91-42-2^/

!!!POSTFIX EXPRESSION EVALUATION ARE AS FOLLOWS..!!!

Result is:2

[student@localhost SE_Comp_A]$ g++ conv_in_po_eval.cpp
[student@localhost SE_Comp_A]$ ./a.out

Enter valid infix Expression: (8*6)/(4-2)^3
    (8*6)/(4-2)^3
After conversion from infix to postfix...
    86*42-3^/

!!!POSTFIX EXPRESSION EVALUATION ARE AS FOLLOWS..!!!

Result is:6

 ***********************************************************************************/

Linked list program to store negative and positive number

Group B: (Assignment No:04)(SPPU Syllabus assignment No :18)
Problem Statement: Write C++ program to store set of negative and positive numbers using linked list. Write functions to 
a) Insert numbers
b) Delete nodes with negative numbers
c) Create two more linked lists using this list, one containing all positive numbers and other containing negative numbers
d) For two lists that are sorted; Merge these two lists into third resultant list that is sorted.

Program Code:
//Author: Prof.Anjali Almale
#include<iostream>
using namespace std;
struct node   //node defined to allocate memory
{
    int num; //To store data
    node *next; //To store address of next node.
};

class numbers  //class name is number
{
 public:

    node *head,*head1,*head2; //data memebers

    numbers() //default constructor
    {
        head=NULL;
        head1=NULL;
        head2=NULL;
    }
    void create();       //member function declaration.
    void display(node *);
    void insert();
    void sort(node *);
    void display2();
    void remove();
    void seperate();
    void merge();
}; //end of class

void numbers::create()
{

  node *current,*new_node;
    char c;
 cout<<"\n------------CREATION OF NUMBERS LIST-------------\n\n ";
    do
    {

    new_node=new node; //dynamic memory allocation
    cout<<"\n Enter the no: \n ";
    cin>>new_node->num; //To store data

    new_node->next=NULL; //make node next null(init)
    if(head==NULL) //check header if null
    {
        head=new_node;
        current=new_node;
    }
    else
    {
        current->next=new_node;
        current=new_node;

    }
    cout<<"\nDo you want to add new member";
    cin>>c;
       }while(c!='n');
}
void numbers::seperate()//To separate the positive numbers and negative numbers.
{
    node *temp,*current1,*current2,*n1,*n2;
    temp=head;

    while(temp!=NULL)
    {
        if((temp->num)<0)
        {
            n1=new node;
            n1->num=temp->num;
            n1->next=NULL;

            if(head1==NULL)
            {
                current1=n1;
                head1=n1;
            }
            else
            {
            current1->next=n1;
            current1=n1;
            }

        }
        else if((temp->num)>=0)
        {
            n2=new node;
            n2->num=temp->num;
            n2->next=NULL;
            if(head2==NULL)

            {
                current2=n2;
                head2=n2;
            }
            else
            {
              current2->next=n2;
              n2->next=NULL;
              current2=n2;
            }
        }
          temp=temp->next;
     }
}

void numbers::display(node *head)//To display the list
{
    node *p;
    p=head;
    if(p==NULL)
    {
        cout<<"\nThe list is Empty";
    }
    else
    {
        while(p!=NULL)
        {
            cout<<p->num<<"\t";
             p=p->next;
        }
    }
}

void numbers::sort(node *head_d) //Before merge u hv to sort them
{
    node *temp1,*temp2,*temp3;
    temp1 = head_d;

 for( ;temp1->next!=NULL;temp1=temp1->next)
 {
     for(temp2=temp1->next;temp2!=NULL;temp2=temp2->next)
     {
         if(temp1->num>temp2->num)
         {
             int temp= temp1->num;
             temp1->num = temp2->num;
             temp2->num = temp;
         }
     }
 }
 temp3 = head_d;

while (temp3!=NULL)
{
cout<<"\t"<< temp3->num;
temp3 =temp3->next;
}
}

void numbers::merge()//To merge both the list
{
    node *temp;
    temp=head1;

    while(temp->next!=NULL)
    {
        temp=temp->next;
    }
    temp->next=head2;
}
void numbers::insert()
{
    node *p,*temp;
        p=new node;
        cout<<"\n\n Enter New Number to be insert  :  ";
        cin>>p->num;
        p->next=NULL;
        temp=head;
        while(temp->next!=NULL)
        {
    temp=temp->next;
        }
    temp->next=p;
}

int main()
{
    numbers n;
    n.create();
    cout<<"\n \nTHE LIST OF +VE AND -VE NUMBERS IS: \n";
    n.display(n.head);
    n.insert();
    cout<<"\n \nTHE LIST AFTER INSERTION IS: \n";
    n.display(n.head);
    n.seperate();
    cout<<"\n\n THE LIST OF ONLY -VE NUMBERS IS: \n";
    n.display(n.head1);
    cout<<"\n\n THE LIST OF ONLY +VE NUMBERS IS: \n";
    n.display(n.head2);
    cout<<"\n\n THE LIST OF ONLY SORTED -VE NUMBERS IS : \n";
    n.sort(n.head1);
    cout<<"\n\n THE LIST OF ONLY SORTED +VE NUMBERS IS : \n";
    n.sort(n.head2);
    n.merge();
    cout<<"\n AFTER MERGE .....THE LIST IS AS FOLLOWS: \n";
    n.display(n.head1);
    cout<<"\n\n THE LIST OF SORTED +VE AND -VE NUMBERS IS : \n";
    n.display(n.head1);
    return 0;
}

/*   OUTPUT *************************************************************


------------CREATION OF NUMBERS LIST-------------


 Enter the no:
 1

Do you want to add new membery

 Enter the no:
 -5

Do you want to add new membery

 Enter the no:
 6

Do you want to add new membery

 Enter the no:
 -7

Do you want to add new membery

 Enter the no:
 -3

Do you want to add new membery

 Enter the no:
 -4

Do you want to add new membery

 Enter the no:
 7

Do you want to add new membern


THE LIST OF +VE AND -VE NUMBERS IS:
1    -5    6    -7    -3    -4    7

 Enter New Number to be insert  :  10


THE LIST AFTER INSERTION IS:
1    -5    6    -7    -3    -4    7    10

 THE LIST OF ONLY -VE NUMBERS IS:
-5    -7    -3    -4

 THE LIST OF ONLY +VE NUMBERS IS:
1    6    7    10

 THE LIST OF ONLY SORTED -VE NUMBERS IS :
    -7    -5    -4    -3

 THE LIST OF ONLY SORTED +VE NUMBERS IS :
    1    6    7    10
 AFTER MERGE .....THE LIST IS AS FOLLOWS:
-7    -5    -4    -3    1    6    7    10

 THE LIST OF SORTED +VE AND -VE NUMBERS IS :
-7    -5    -4    -3    1    6    7    10

********************************************************************************************/

Tuesday, 6 September 2016

C++ program using stack to check whether given expression is well parenthesized or not.

Group C: Assignment No: 01 (SPPU Syllabus Assignment No:24)

Problem Statement:
In any language program mostly syntax error occurs due to unbalancing delimiter such as (),{},[]. Write C++ program using stack to check whether given expression is well parenthesized or not.


Program Code:

//============================================================================
// Name        : wellformness.cpp
// Author      : Nitin Shivale
// Version     : 1
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
#define size 10

class stackexp
{
    int top;
    char stk[size];
public:
    stackexp()
    {
     top=-1;
    }
    void push(char);
    char pop();
    int isfull();
    int isempty();
};

void stackexp::push(char x)
{
    top=top+1;
    stk[top]=x;
}

char stackexp::pop()
{
    char s;
    s=stk[top];
    top=top-1;
    return s;
}

int stackexp::isfull()
{
    if(top==size)
        return 1;
    else
        return 0;
}

int stackexp::isempty()
{
    if(top==-1)
        return 1;
    else
        return 0;
}

int main()
{
    stackexp s1;
    char exp[20],ch;
    int i=0;
    cout << "\n\t!!Well Formness of Parenthesis..!!!!" << endl; // prints !!!Hello World!!!
    cout<<"\nEnter the expression to check whether it is in well form or not :  ";
    cin>>exp;
    if((exp[0]==')')||(exp[0]==']')||(exp[0]=='}'))
    {
        cout<<"\n Invalid Expression.....\n";
        return 0;
    }
    else
    {
        while(exp[i]!='\0')
        {
            ch=exp[i];
            switch(ch)
            {
            case '(':s1.push(ch);break;
            case '[':s1.push(ch);break;
            case '{':s1.push(ch);break;
            case ')':s1.pop();break;
            case ']':s1.pop();break;
            case '}':s1.pop();break;
            }
            i=i+1;
        }
    }
    if(s1.isempty())
    {
        cout<<"\nExpression is well parenthesis...\n";
    }
    else
    {
        cout<<"\nSorry !!! Invalid Expression or not in well parenthesized....\n";
    }
    return 0;
}

/******************* output   *****************************************************

  !!Well Formness of Parenthesis..!!!!

Enter the expression to check whether it is in well form or not :  (m<(n[8]+0))

Expression is well parenthesis...


!!Well Formness of Parenthesis..!!!!

Enter the expression to check whether it is in well form or not :  )(m+n)*(a-b)

 Invalid Expression.....



     !!Well Formness of Parenthesis..!!!!

Enter the expression to check whether it is in well form or not :  (m+b(n[8)/2+3)

Sorry !!! Invalid Expression or not in well parenthesized....


*********************************************************************************/


Tuesday, 30 August 2016

Pinnacle Club implementation using Singly Linked List

Group B : Assignment No: 01 (SPPU Syllabus Assignment No :14)
Problem Statement:
Department of Computer Engineering has student's club named 'Pinnacle Club'. Students of Second, third and final year of department can be granted membership on request. Similarly one may cancel the membership of club. First node is reserved for president of club and last node is reserved for secretary of club. Write C++ program to maintain club member‘s information using singly linked list. Store student PRN and Name. Write functions to
a)Add and delete the members as well as president or even secretary.
b)Compute total number of members of club
c)Display members
d)Display list in reverse order using recursion
e) Two linked lists exists for two divisions. Concatenate two lists.



Program Code:

//============================================================================
// Name        : panclub.cpp
// Author      : Nitin Shivale (9850562515)
// Version     : 1
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<stdlib.h>
#include<string.h>
using namespace std;
//data structure for student information i:e node
struct node
{
 int prn;
 char name[20];
 node *next;
};

class panclub
{
    int num,cnt;
    char nm[20];  //Data memebers
    node *head;
 public:
    panclub()//Constructor to initialize object
    {
     num=cnt=0;
     head=NULL;
    }
    node *create();
    void display(node *);
    node *concat(node *,node *);  //Memeber Functions with arguments
    void reverse(node *);
    node* insert_president(node *);
    void insert_sec(node *);
        void insert_member(node *);
    node* del_president(node *);
        node* del_secretary(node *);
        node* del_member(node *);
};

//To Create the list of Divisions.
node* panclub::create()
{
    node *temp,*n1;
    temp=n1=NULL;
    //int flag=1;
    //char ans='y';
    cout<<"\nHow many students data u want to insert in panclub database: ";
    cin>>cnt;
    do
    {
        n1=new node; //first of allocate the memory for all feilds of struct.
        cout<<"\nEnter the prn number of student:";
        cin>>num;
        n1->prn=num;
        //storing the prn in node feild prn;
        cout<<"\nEnter the name of student:";
        cin>>nm;
        strcpy(n1->name,nm);
        //Storing the name in node feild name.;
        n1->next=NULL; //making the next feild null.
        if(head==NULL) //check for head is empty.
        {
            head=n1;   //make new node as head
            temp=head;
        }
        else
        {
            temp=head;
            while(temp->next!=NULL) //attach at the end of list
            {
                temp=temp->next;
            }
            temp->next=n1;
        }
        cnt--;
    }while(cnt>0);

    return head;
}

void panclub::display(node *head) //display the list of both divisions.
{
 node *temp;
 temp=head;
 while(temp!=NULL)
 {
     if(temp->next==NULL)
     {
      cout<<"["<<temp->prn<<"|"<<temp->name<<"]->NULL";
     }
     else
     {
      cout<<"["<<temp->prn<<"|"<<temp->name<<"]->";
     }
     temp=temp->next;
 }
}

node* panclub::concat(node *head1,node *head2) //To concatinate both the divisions data in one list.
{
    node *head3,*temp,*temp1;
    head3=temp=temp1=NULL;
    temp=head1;
    head3=head1;
    while(temp->next!=NULL)
    {
        temp=temp->next;
    }
    temp1=head2;
    temp->next=temp1;
    return head3;
}
void panclub::reverse(node *head)
{
    node *temp;
    temp=head;
    if(temp==NULL)
        return;
    reverse(temp->next);
    cout<<"["<<temp->prn<<"|"<<temp->name<<"]->";
}

node* panclub::insert_president(node *head)
{
 node *temp,*n2;
 temp=n2=NULL;
 temp=head;
 n2=new node;
 cout<<"\nEnter the PRN number of President: ";
 cin>>n2->prn;
 cout<<"\nEnter the name of President: ";
 cin>>n2->name;
 n2->next=temp;
 head=n2;
 return head;
}

void panclub::insert_member(node *head)
{
 node *temp,*n2;
 int pn;
 temp=head;
 n2=new node;
 cout<<"\nEnter the PRN number of Member: ";
 cin>>n2->prn;
 cout<<"\nEnter the name of Member: ";
 cin>>n2->name;
 n2->next=NULL;
 cout<<"\nEnter the PRN number after which u want to add this member: ";
 cin>>pn;
 while(temp!=NULL)
 {
  if(temp->prn==pn)
  {
   n2->next=temp->next;
   temp->next=n2;
   break;
  }
  temp=temp->next;
 }
 cout<<"\n\nMember added sucessfully....!!";
}

void panclub::insert_sec(node *head)
{
 node *temp,*n2;
 temp=head;
 n2=new node;
 cout<<"\nEnter the PRN number of Secretary: ";
 cin>>n2->prn;
 cout<<"\nEnter the Name of Secretary: ";
 cin>>n2->name;
 n2->next=NULL;
 while(temp->next!=NULL)
 {
  temp=temp->next;
 }
 temp->next=n2;
}
//delete the president node from list
node* panclub::del_president(node *head)
{
 node *temp;
 temp=head;
 head=temp->next;
 free(temp);
 return head;
}
//Delete the secretary node from the list.
node* panclub::del_secretary(node *head)
{
 node *temp,*t1;
 temp=head;
 while(temp->next!=NULL)
 {
  t1=temp;
  temp=temp->next;
 }
 t1->next=NULL;
 free(temp);
 return head;
}

//Delete the memeber from the list.

node* panclub::del_member(node *head)
{
 node *temp,*t1;
 int pn;
 temp=head;
 cout<<"\nEnter the PRN number after which u want to delete member: ";
 cin>>pn;
 while(temp!=NULL)
 {
  if(temp->prn==pn)
  {
   t1=temp->next;
   temp->next=t1->next;
   free(t1);
   break;
  }
  temp=temp->next;
 }
 cout<<"\n\nMember removed sucessfully....!!";
 return head;
}
int main()
{
    panclub p1,p2,p3;
    node *h1,*h2,*h3;
    h1=h2=h3=NULL;
    int ch;
    cout << "\n\t!!!Group B:Assignment No:01!!!" << endl; // prints !!!Assignment number and group!!!
   do
   {
    cout<<"\n\n1.Enter data of SE A Division:";
    cout<<"\n2.Enter data of SE B Division:";
    cout<<"\n3.Concatination of List..";
    cout<<"\nEnter your choice: ";
    cin>>ch;
    switch(ch)
    {
     case 1:
            cout<<"\n\nPlease enter the student info who is register memeber..";
            cout<<"\n\nEnter the Panclub Data of SE A Division:\n";
            h1=p1.create();
        cout<<"\nSE Comp Division A List are as follows..\n\n";
        p1.display(h1);
        cout<<"\n\nReverse List of SE Div A:\n\n";
        p1.reverse(h1);
        p1.insert_sec(h1);
        cout<<"\nAfter insertion of Secretary: \n";
        p1.display(h1);
        h1=p1.insert_president(h1);
        cout<<"\nAfter insertion of President: \n";
        p1.display(h1);
        p1.insert_member(h1);
        cout<<"\n After insertion of member...\n";
        p1.display(h1);
        h1=p1.del_president(h1);
        cout<<"\n\nAfter deletion of president...\n";
        p1.display(h1);
        h1=p1.del_secretary(h1);
        cout<<"\n\nAfter deletion of secretary...\n";
        p1.display(h1);
        h1=p1.del_member(h1);
        cout<<"\n\nAfter deletion of member...\n";
        p1.display(h1);
        break;
    case 2:
        cout<<"\n\nEnter the Panclub Data of SE B Division:\n";
        h2=p2.create();
        cout<<"\nSE Comp Division B List are as follows..\n\n";
        p2.display(h2);
        cout<<"\n\nReverse List of SE Div B:\n\n";
        p1.reverse(h2);
        p2.insert_sec(h2);
        cout<<"\nAfter insertion of Secretary: \n";
        p2.display(h2);
        h2=p2.insert_president(h2);
        cout<<"\nAfter insertion of President: \n";
        p2.display(h2);
        p2.insert_member(h2);
        cout<<"\n After insertion of member...\n";
        p2.display(h2);
        h2=p2.del_president(h2);
        cout<<"\n\nAfter deletion of president...\n";
        p1.display(h2);
        h2=p2.del_secretary(h2);
        cout<<"\n\nAfter deletion of secretary...\n";
        p1.display(h2);
        h2=p2.del_member(h2);
        cout<<"\n\nAfter deletion of member...\n";
        p2.display(h2);
            break;
    case 3:
        h3=p3.concat(h1,h2);
        cout<<"\n\nThe concatenation of Div : A and Div : B of SE Comp Class are as follows.\n\n";
        p3.display(h3);
            break;
  }
 }while(ch!=4);
        return 0;

}


/********************** OUTPUT **********************************************
[student@localhost Documents]$ g++ panclub.cpp
[student@localhost Documents]$ ./a.out

    !!!Group B:Assignment No:01!!!


1.Enter data of SE A Division:
2.Enter data of SE B Division:
3.Concatination of List..
Enter your choice: 1


Please enter the student info who is register memeber..

Enter the Panclub Data of SE A Division:

How many students data u want to insert in panclub database: 2

Enter the prn number of student:333

Enter the name of student:nitin

Enter the prn number of student:444

Enter the name of student:sham

SE Comp Division A List are as follows..

[333|nitin]->[444|sham]->NULL

Reverse List of SE Div A:

[444|sham]->[333|nitin]->
Enter the PRN number of Secretary: 555

Enter the Name of Secretary: sachin

After insertion of Secretary:
[333|nitin]->[444|sham]->[555|sachin]->NULL
Enter the PRN number of President: 111

Enter the name of President: tejas

After insertion of President:
[111|tejas]->[333|nitin]->[444|sham]->[555|sachin]->NULL
Enter the PRN number of Member: 222

Enter the name of Member: ram

Enter the PRN number after which u want to add this member: 111


Member added sucessfully....!!
 After insertion of member...
[111|tejas]->[222|ram]->[333|nitin]->[444|sham]->[555|sachin]->NULL

After deletion of president...
[222|ram]->[333|nitin]->[444|sham]->[555|sachin]->NULL

After deletion of secretary...
[222|ram]->[333|nitin]->[444|sham]->NULL
Enter the PRN number after which u want to delete member: 222


Member removed sucessfully....!!

After deletion of member...
[222|ram]->[444|sham]->NULL

1.Enter data of SE A Division:
2.Enter data of SE B Division:
3.Concatination of List..
Enter your choice: 2


Enter the Panclub Data of SE B Division:

How many students data u want to insert in panclub database: 3

Enter the prn number of student:123

Enter the name of student:sudhir

Enter the prn number of student:124

Enter the name of student:mohit

Enter the prn number of student:125

Enter the name of student:kohali

SE Comp Division B List are as follows..

[123|sudhir]->[124|mohit]->[125|kohali]->NULL

Reverse List of SE Div B:

[125|kohali]->[124|mohit]->[123|sudhir]->
Enter the PRN number of Secretary: 126

Enter the Name of Secretary: Dough

After insertion of Secretary:
[123|sudhir]->[124|mohit]->[125|kohali]->[126|Dough]->NULL
Enter the PRN number of President: 121

Enter the name of President: Bill

After insertion of President:
[121|Bill]->[123|sudhir]->[124|mohit]->[125|kohali]->[126|Dough]->NULL
Enter the PRN number of Member: 122

Enter the name of Member: Gates

Enter the PRN number after which u want to add this member: 111


Member added sucessfully....!!
 After insertion of member...
[121|Bill]->[123|sudhir]->[124|mohit]->[125|kohali]->[126|Dough]->NULL

After deletion of president...
[123|sudhir]->[124|mohit]->[125|kohali]->[126|Dough]->NULL

After deletion of secretary...
[123|sudhir]->[124|mohit]->[125|kohali]->NULL
Enter the PRN number after which u want to delete member: 123


Member removed sucessfully....!!

After deletion of member...
[123|sudhir]->[125|kohali]->NULL

1.Enter data of SE A Division:
2.Enter data of SE B Division:
3.Concatination of List..
Enter your choice: 3


The concatenation of Div : A and Div : B of SE Comp Class are as follows.

[222|ram]->[333|nitin]->[123|sudhir]->[125|kohali]->NULL

1.Enter data of SE A Division:
2.Enter data of SE B Division:
3.Concatination of List..
Enter your choice: 4
[student@localhost Documents]$


   

**************************************************************************************/