CBSE Guess > Papers > Important Questions > Class XII > 2010 > Computer Science > Computer Science By Ravi Kiran
CBSE CLASS XII
Q.2. Evaluate the following postfixnotation of expression : 15 3 2 + / 7 + 2. * 2
Ans:
Children, Try this answer as an assignment.
DELHI . 2006
Q.1. class queue
{ int data[10] ;
int front, rear ;
public :
queue( ) { front = - 1 ; rear = - 1 ; }
void add( ) ; //to add an element into the queue
void remove( ) ; //to remove an element from the queue
void Delete(int ITEM( ) ; //to delete all elements which are equal to ITEM
} ;
Complete the class with all function definitions for a circular array Queue. Use another queue to
transfer data temporarily.
Solution:
void queue::add( )
{ if((front= = 0 && rear = = 9) | | (front= =rear+1)
cout<<”\nQueue Overflow”;
else if (rear= = -1)
{ front=rear=0;
cout<<”\nEnter the element to be inserted”;
cin>>data[rear];
}
else if(rear= =9)
{ rear=0;
cout<<”\nEnter the element to be inserted”;
cin>>data[rear];
}
else
{ rear++;
cout<<”\nEnter the element to be inserted”;
cin>>data[rear];
}
}
void queue::remove( )
{ if(front= = -1)
cout<<”\nQueue Underflow…”;
else
{ cout<<”\nThe element to be deleted”<<data[front];
if(front= =rear)
front=rear=-1;
else if (front= =9)
front=0;
else
front++;
}
}
void queue::Delete(int ITEM )
{
}
Paper By Mr. Ravi Kiran
Email Id : [email protected] |