Important Questions

CBSE Guess > Papers > Important Questions > Class XII > 2010 > Computer Science > Computer Science By Ravi Kiran

CBSE CLASS XII

Q.3. Write theequivalent infix expression for 10, 3, *, 7, 1, --,*, 23, +

Solution:

10, 3, *, 7, 1, - , *, 23, + This is in Postfix form( ie Operator will come after the operand(s));.
Infix form means Operator must come in between the operands.
10, 3, *, 7, 1, - , *, 23, +
Prefix: 10 * 3, 7 – 1,*,23,+
(10 * 3) * (7 – 1),23,+
(10 * 3) * (7 – 1) + 23

DELHI : 2005

Q.1. Write a function in C++ to perform a PUSH operation in a dynamically allocated stack considering the following :
struct Node
{
int X,Y ;
Node *Link ;
} ;
class STACK
{
Node *Top ;
public :
STACK( ) {Top = Null ;}
void PUSH( ) ;
void POP( ) ;
~STACK( ) ;
} ;

Solution:

struct Node
{
int X,Y ;
Node *Link ;
} ;
class STACK
{
Node *Top ;
public :
STACK( ) {Top = NULL ;}
void PUSH( ) ;
void POP( ) ;
~STACK( ) ;
} ;
void STACK::PUSH( )
{
Node *Temp;
Temp=new Node;
if(Temp= =NULL)
{
cout<<”\nNo memory to create the node…”;
exit(1);
}
cout<<”Enter the value of X and Y”;
cin>>TempX>>TempY;
TempLink=Top;
Top=Temp;
}
}

Paper By Mr. Ravi Kiran
Email Id : [email protected]