Page 142 - C++
P. 142
{
int M;
public :
void DISPLAY (void);
};
(i) Name the base class and derived class of the class COUNTRY.
(ii) Name the data member(s) that can be accessed from function DISPLAY().
(iii) Name the member function(s), which can be accessed from the objects of class STATE.
(iv) Is the member function OUTPUT() accessible by the objects of the class COUNTRY?
3. (a) Write a function in C++, which accept an integer array and its size as arguments and swap the
elements of every even location with its following odd location.
Example: if an array of nine elements initially contains the elements as 2,4,1,6,5,7,9,23,10 Then the
function should rearrange the array as 4,2,6,1,7,5,23,9,10 [2]
(b) An array A[50][20] is stored in the memory along the row with each of its elements occupying
8 bytes. Find out the location of A[5][10], if A[4][5] is stored at 4000. [3]
(c) Write a function in C++ to perform a Add and Delete operation in a dynamically allocated Queue
considering the following: [4]
struct node
{
intempno;
char name[20];
floatsal;
Node *Link;
};
(d) Write a user defined function named upperhalf( ) which takes a 2D array A, with size n rows and n
columns as arguments and print the upper half of the matrix. [3]
Example of Matrix Output
1 2 3 1 2 3
6 7 8 7 8
2 3 4 4
(e) Convert the following infix expressions to postfix expressions using stack
A + (B * C) ^ D – (E / F – G) [2]
4. (a) Observe the program segment given below carefully, and answer the question that follows: [1]
#include<fstream.h>
class LAB
{
int expno;
char expr[30], checked;
float marks;
public:
void EnterExp( ); //function to enter experiment details
void ShowExp( ); //function to display Experiment details
char RChecked( ) { return checked; } //function to return checked
void AssignM(int M) //function to assign Marks
{
MTP.4 Computer Science with C++ —CBSE XII