Important Questions

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

CBSE CLASS XII

Solution:

struct Book
{ int BNo ;
char BName[20] ;
Book *Next ;
} ;
class Stack
{ Book *Top;
public:
Stack( )
{ Top = NULL; }
void Push( );
void Pop( );
void Display( );
};
void Stack::Pop( )
{ Book *Temp;
If( Top= = NULL)
cout<<”Stack Underflow…”;
else
{ cout<<”\nThe Book number of the element to delete: “<<TopBNo;
cout<<”\nThe Book name of the element to delete: “<<TopBName;
Temp=Top;
Top=TopNext;
Delete Temp;
}
}

Q.2. Evaluate the following postfix notation of expression : 25 8 3 - / 6 * 10 + 2.

Ans:

Children, Try this answer as an assignment.

OUTSIDE DELHI 2007

Q.1. Write a function in C++ to delete a node containing customer’s information, from a dynamically allocated Queue of Customers implemented with the help of the following structure.
struct Customer
{ int CNo ;
char CName[20] ;
Customer *Link ;
} ;

Solution:

struct Customer
{ int CNo ;
char CName[20] ;
Customer *Link ;
} ;
class Queue
{ Customer *front,*rear;
public:
Queue( )
{ front=rear=NULL; }
void Insert( );
void Delete( );
void Display( );
};
void Queue::Delete( )
{ Customer *Temp;
if(front= =NULL)
cout<<”Queue Underflow. No element to delete”;
else
{ cout<<”\n The customer number for the element to delete”<<frontCNo;
cout<<”\n The customer name for the element to delete”<<frontCName;
Temp=front;
front = frontLink;
delete Temp;
}
}

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