Important Questions

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

CBSE CLASS XII

DELHI 2003

Q.1. Evaluate the following postfix expression using a stack and show the contents of stack after execution of each operation: 20, 45, +, 20, 10, -, 15, +, *

Ans:

Children, Try this answer as an assignment.

Q.2. Consider the following portion of a program, which implements passengers Queue for a train. Write the definition of function. Insert (whose prototype is shown below); to insert a new node in the queue with required information.
struct NODE
{ long Ticketno;
char PName[20];//Passengers Name
NODE * Next;
};
class Queueoftrain
{ NODE * Rear, * Front;
public :
Queueoftrain( ) { Rear = NULL; Front = NULL:}
void Insert( );
void Delete( );
~Queueoftrain( );
} ;
Solution:
void Queueoftrain::Insert( )
{ NODE *ptr;
ptr=new NODE;
if(ptr= = NULL)
{
cout<<”\nNo memory to create a new node….”;
exit(1);
}
cout<<”\nEnter the Ticket Number….”;
cin>>ptrTicketno;
cout<<”\nEnter the Passenger Name..”;
gets(ptrPName);
ptrNext=NULL;
if(rear= = NULL)
front=rear=ptr;
else
{
rearNext=ptr;
rear=ptr;
}
}

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