2015 QUESTION PAPER
(a) Write the definition of a function Change(int P[], int N) in C++, which should change all the multiples of 10 in the array to 10 and rest of the elements as 1. For example, if an array of 10 integers is as follows:
After executing the function, the array content should be changed as follows:
(b) A two dimensional array ARR[50][20] is stored inthe memory along the two with each of its elements occupying 4 bytes. Find the address of the element ARR[30][10], if the element ARR[10][5] is stored at the memory location 15000.
(c) Write the definition of a member function Push() in C++, to add a new book in a dynamic stack of BOOKS considering the following code is already included in the program:
struct BOOKS
{
char ISBN[20], TITLE[80];
BOOKS*Link;
};
class STACK
{
BOOKS *Top;
public:
STACK() { Top=NULL; }
void PUSH();
void POP();
~STACK();
};
(d) Write a function REVROW(int P[][5], int N, int M) in C++ to display the content of a two dimensional array, with each row content in reverse order.
For example, if the content of array is as follow:
The function should display output as:
(e) Convert the following Infix expression to its equivalent Postfix expression, showing the stack content for each step of conversion:
U + V + R / ( S – T )
[2+3+4+3+2=14]
AnswerS
(a)
Output-
(b)
Element size =4 bytes
Lr=Lc=0;
B=?
ARR[10][5]=15000
ARR[30][10]=?
ARR[I][J]= B + W[n(I-Lr) + (J-Lc)]
15000 = B + 4[20(10-0)+(5-0)]
15000 = B + 4[ 200+5]
15000 = B + 4[205]
B = 15000 – 820
B= 14180
Now, put the value of base address to evaluate the address of cell ARR[30][10]
ARR[30][10]= 14180 + 4[20(30-0) + (10-0)]
= 14180 + 4[600+10]
= 14180 + 2440
ARR[30][10]= 16620 Ans.
(c)
void STACK::PUSH()
{
BOOKS *temp;
temp=new BOOKS;
if(temp==NULL)
cout<"Stack is Full";
else
{
cout<"Enter ISBN:";
cin>temp->ISBN;
cout<”Enter TITLE: ”:
cin>temp->TITLE;
temp->Link=top;
top=temp;
}
}
(d)
(e)
U * V + R / (S – T)
Stack status for infix to postfix conversion is shown below-
(U * V) + (R / (S – T))
2014
(a) Write code for a function offEven(int s[], int N) in C++, to add 5 in all the odd values and 10 in all the even values of the array S.
Example: If the original content of the array S is
The modified content will be:
(b) An array T[25][20] is stored along the row in the memory with each element requiring 2 bytes of storage. If the base address of array T is 42000, find out the location of T[10][15]. Also, find the total number of elements present in this array.
(c) Write a user-defined function SumLast3(int A[][4], int N, int M) in C++ to find and display the sum of all the values, which are ending with 3 (i.e., units place is 3). For example if the content of array is:
33 / 13 / 9299 / 3 / 12
The output should be 49.
(d) Evaluate the following postfix expression. Show the status of stack after execution of each operation separately:
F, T, NOT, AND, F, OR, T, AND
(e) Write a function POPBOOK() in C++ to perform delete operation from a Dynamic Stack, which contains Bno and Title. Consider the following definition of NODE, while writing your C++ code.
struct NODE
{
int Bno;
char Title[20];
NODE *Link;
};
[3+3+2+2+4=14]
ANSWERS
#include< iostream.h>
#include< conio.h>
void oddEven(int s[], int N)
{
for(int i=0;i
{
if(s[i]%2==0)
s[i]=s[i]+10;
else
s[i]=s[i]+5;
}
}
void main()
{
clrscr();
int i, arr[5];
cout< "Enter five elements in the array";
for(i=0;i<5;i++)
cin > arr[i];
cout < "The array is: ";
for(i=0;i<5;i++)
cout < arr[i]< " , ";
// calling function for adding values
oddEven(arr,5);
cout< "The updated array is: ";
for(i=0;i<5;i++)
cout< arr[i]< " , ";
getch();
}
(b)
Base Address = 42000
Element size W = 2 bytes
Rows in Array = 25
Columns in Array = 20
Lr, Lc=0,0
Location of array I, J = 10, 15
Row Major:
T[I][J]=B+W[C(I-Lr)+ (J-Lc)]
T[10][15 ] = 42000 + 2 * [(20(10-0 ) + (15-0))]
=42000+ 2*(200+15)
=42000+430
=42430
Total Number of elements present in array T is R * C i.e., 25 * 20 = 500
(c)
#include < conio.h>
#include < iostream.h>
void SumLast3(int A[][3], int N, int M)
{ int num,last,sum=0;
for(int i=0; i
{
for(int j=0; j
{
num=A[i][j];
last=num%10;
if(last==3)
sum=sum+num;
}
}
cout< "Sum of the digits ending with 3 is: "< sum;
}
void main()
{
clrscr();
int arr[2][3] ={{33, 13, 92}, {99, 3, 12}};
SumLast3(arr,2,3);
getch();
}
(d)
The Given postfix notation:
F, T, NOT, AND, F, OR, T, AND
Push each element in the stack bucket one by one.
(e)
struct NODE
{
int BNo;
char Title[20];
NODE *link;
};
void STACK::POPBOOK()
{
NODE *temp;
//structure pointer top is holding the address of the top node
if(top==NULL) // Value NULL is initially assigned to top
cout< "Stack is Empty";
else
{
temp=top;
temp=temp->link;
top=temp;
cout< "The element is popped out.";
}
}
2013
(a) Write a code for a function void ChangeOver(int P[ ], int N) in C++, which re-positions all the elements of the array by shifting each of them to the next position and by shifting the last element to the first position.
For example: If the content of the array is:
0 / 1 / 2 / 3 / 412 / 15 / 17 / 13 / 21
The changed content will be:
0 / 1 / 2 / 3 / 421 / 12 / 15 / 17 / 13
(b) An array T[15][10] is stored along with the row in the memory with each element requiring 8 bytes of storage. If the base address of the array T is 14,000, then find out the location of T[10][7].
(c) Write a user-defined function
DispTen(int A[ ][4], int N, int M)
in C++ to find and display all the numbers, which are divisible by 10. For example, if the content of the array is:
12 / 20 / 132 / 10 / 30
The output should be:
20 10 30
(d) Evaluate the following postfix expression. Show the status of the stack after the execution of each operation:
5, 2, *, 50, 5, /, 5, -, +
(e) Write a function QDELETE() in C++ to perform the delete operation on a Linked Queue, which contains the Passenger no. and Passenger name. Consider the following definition of node in the code:
struct node
{
long int Pno;
char Pname[20];
node *Link;
};
[3+3+2+2+4 = 14]
ANSWERS
Answer:
(a).
#include< iostream.h >
#include< conio.h >
void ChangeOver(int P[], int N)
{
int temp;
temp=P[N-1];
for(int i=N-1;i>0;i--)
{
P[i]=P[i-1];
}
P[0]=temp;
}
void main()
{
clrscr();
int arr[20],range,i;
cout < "nEnter Range: ";
cin > range;
cout < "nEnter "< range< " elements:";
for(i=0;i
cin > arr[i];
cout < "nThe array before conversion is: ";
for(i=0;i
cout < arr[i]< " ,t";
ChangeOver(arr,range);
cout < "nThe array before conversion is: ";
for(i=0;i
cout < arr[i]<" ,t";
getch();
}
(b)
B= 14000
E= 8 Bytes
Lr=Lc=0
T[10][7]=?
Row Major:
P[10][7] =B+E[C(I-Lr)+(J-Lc)]
= 14000 + 8[10(10-0) + (7-0)]
= 14000 + 7(107)
= 14000 + 749
= 14749 Ans
(c) #include< iostream.h >
#include< conio.h >
void DispNTen(int L[][4], int R, int C)
{
cout < "nThe Divisible elements are: ";
for(int i=0; i < R ; i++)
{
for(int j = 0; j < C; j++)
{
if(L[i][j]%10==0)
cout < L[i][j]< "t";
}
}
}
void main()
{
clrscr();
int M[4][4],r,c,i,j;
cout < "nEnter Rows: ";
cin > r;
cout < "nEnter Cols: ";
cin > c;
cout < "nEnter elements:";
for(i = 0 ; i < r ; i++)
for(j = 0 ; j < c ; j++)
cin > M[i][j];
cout < "nThe Martrix is: ";
for(i = 0 ; i < r ; i++)
{
cout <"nn";
for(j= 0 ; j < c ; j++ )
cout < M[i][j] < "t";
}
DispNTen(M,r,c);
getch();
}
(d) 5, 2, *, 50, 5, /, 5, -, +
(e)
void Queue::QDELETE()
{
node *temp;
if(startPtr==NULL)
cout<”Queue is Empty (underflow…)”;
else
{
temp= startPtr;
startPtr=startPtr->link;
cout < ”nThe record deleted is: ”;
cout < ”n PNo: ”< temp->Pno;
cout < ”n Name : ”< temp->Pname;
delete temp;
}
}
______2012
a) Write a function SWAP2BEST (int ARR[ ],int Size) in C++ to modify the content of the array in such a way that the elements, which are multiples of 10 swap with the values present in the very next position in the array.
For example:
If the content of Array ARR is
90, 56, 45, 20, 34, 54
The content of array ARR should become
56, 90, 45, 34, 20, 54
b)An arrayT[20][10] is stored in the memory along the column with each of the elements occupying 2 bytes. Find out the memory location of T[10][5], if the element[2][9] is stored at the location 7600.
c) Write a function in C++ to perform Insert operation in a static circular Queue containing Book’s information (represented with the help of an array of structure BOOK).
struct BOOK
{
long Accno; //Book Accession Number
char Title[20]; //Book Title
};
d) Write a function ALTERNATE (int A[ ][3], int N, int M) in C++ to display all alternate elements from two-dimensional array A (starting fromA[0][0]).
For example:
If the array is containing:
23 54 76
37 19 28
62 13 19
The output will be:
23 76 19 62 19
e) Evaluate the following POSTFIX notation. Show the status of stack after every step of evaluation (i.e. after each operator):True, False, NOT, AND, False, True, OR, AND
[3+3+4+2+2 = 14]
ANSWERS
(a). A C++ function SWAP2BEST(int ARR[], int Size) that swaps the elements which are multiple of 10, with their very next positioned element.
void SWAP2BEST (int ARR[], int Size)
{
int temp;
for(int i = 0; i < SIZE; i++)
{
if(ARR[i]%10 == 0)
{ //swap with the next element
temp = ARR[i];
ARR[i] = ARR[i+1];
ARR[i+1] = temp;
i++; //reach next to the number that has been swapped
}
}
}
(b).B= ?
E=2 Bytes
Lr=Lc=0
S[2][9]=7600
Column Major:
S[I][J]=B+E[(I-Lr)+R(J-Lc)]
S[2][9] = B + 2[(2-0)+20(9-0)]
7600 = B + 2(182)
B = 7600-364
B = 7236
Now Address of S[5][10] is:
S[10][5] = B+ E[(I-Lr)+R(J-Lc)]
= 7236 + 2[(10-0] + 20(5-0)]
= 7236 + 2(110)
= 7236 + 220
= 7456 Ans
(c). // declare a global variables
Const int size=10;
int front,rear;
front=rear=-1;
Book B[size];
void insert_in_CQ( )
{
if(front==0 & rear==size-1)||(front==rear+1))
cout< ”Underflow”;
else if(rear==-1)
front=rear=0;
else
{
rear++;
cout< ”Enter Accession No:”;
cin>B[rear].acc;
cout< ”Enter Title: ”;
cin>B[rear].Title;
}
}
(d). Function ALTERNATE(int A[][3], int N, int M) that displays all alternate elements from 2Dimensional array A.
void ALTERNATE(int A[ ][3 ], int N, int M)
{
for(int i = 0; i < N*M; i = i+2)
{
cout< A[i/M][i%M]< "n";
}
}
(e). The Given postfix notation:
True, False, NOT, AND, False, True, OR, AND
Push each element in the stack bucket one by one.
Therefore the Answer is True.
2011
a)Write a Get2From1() function in C++ to transfer the content from one array ALL[ ] to two different arrays Odd[ ] and Even[ ]. The Odd[ ] array should contain the values from odd positions(1,3,5…) of ALL[ ] and Even[ ] array should contain the values from even positions (0,2,4,…) of ALL[].
Example :
If the ALL[ ] array contains
12,34,56,67,89,90
The Odd[ ] array should contain
34,67,90
And the Even[ ] array should contain
12,56,89
b) An array G[50][20] is stored in the memory along the row with each of its elements occupying 8 bytes. Find out the location of G[10][15], if G[0][0] is stored at 4200.
c) Write a function in C++ to perform Delete operation on a dynamically allocated Queue containing Members details as given in the following definition of NODE:
struct NODE
{
long Mno; //Member Number
char Mname[20]; //Member Name
NODE *Link;
};
d)Write a DSUM() function in C++ to find sum of Diagonal Elements from a NxN Matrix.
(Assuming that the N is a odd number)
e)Evaluate the following postfix notation of expression: True ,False,NOT,AND,True,True,AND,OR
[ 3+3+4+2+2 =14 ]
ANSWERS
Answer:
(a)
void Get2From1()
{
int All[]={12,34,56,67,89,90};
int Odd[3];
int Even[3];
int i,j,k;
j=k=0;
for(i=0;i<6;i++)
{
if(i%2==0)
{
Even[j++]=All[i];
}
else
Odd[k++]=All[i];
}
cout < "All Array :n";
for(j=0;j<6;j++)
cout<
cout < "Even Index Array :n";
for(j=0;j<3;j++)
cout<
cout < "Odd Index Array :n";
for(j=0;j<3;j++)
cout<
}
(b) Given:
W=8,N=20,B=4200
G[10][15]=4200+8(20(10-0)+(15-0))
=4200+8(200 + 15)
=4200+8(215)
=4200+1720
=5920
(c) void queue :: quedel()
{
node *temp;
int val;
if(front ==NULL)
{
cout < "Queue Empty";
}
else
{
temp = front;
front = front -> Link
val = temp -> Mno;
cout < "Deleted value is" < val;
Delete temp;
}
if(front == NULL)
Rear=front;
}
(d)
void DSUM()
{
int a[n][n], sum=0;
for ( int i = 0 ; i < n ; i ++)
{
for( int j = 0 ; j < n ; j ++)
{
cin > a[i][j];
}
}
for ( int i = 0 ; i < n ; i + +)
{
for( int j = 0 ; j < n; j + +)
{
if( i==j )
{
sum = sum +a[i][j];
}
}
}
cout < " Sum of dialgonal elementsis: "< sum;
}
(e)
Scanned Elements / Operation / StackTrue / PUSH True / True
False / PUSH False / True, False
NOT / NOT(False) / True, True
AND / AND(True, True) / True
True / PUSH True / True, True
True / PUSH True / True, True, True
AND / AND(True, True) / True, True
OR / OR(True, True) / True
______
2010
a) Write a function REASSING() in C++ which accepts an array of integers and its size as parameters and divide all those array elements by 5 which are divisible by 5 and multiply other array elements by 2.(3)
Sample Input Data of the array
A [ 0 ] / A [ 1 ] / A [ 2 ] / A [ 3 ] / A [ 4 ]20 / 12 / 15 / 60 / 32
Content of the array after calling REASSIGN() function
A [ 0 ] / A [ 1 ] / A [ 2 ] / A [ 3 ] / A [ 4 ]4 / 24 / 3 / 12 / 64
b) An array T [ 90 ] [ 100 ] is stored in the memory along the column with each of the elements occupying 4 bytes. Find out the memory location for the element T [ 10 ] [40 ] , if the Base Address of the array is 7200.(3)
c) Write a complete program in C++ to implement dynamically allocated Queue containing names of cities.(4)
d) Write a function int ALTERSUM (int B [ ] [ 5 ] ,int N, int M)in C++ to find and return the sum of elements from all alternate elements of a two- dimensional array starting from B [ 0 ] [ 0 ] .(2)
Hint:
If the following is the content of the array.
B [ 0 ] [ 0 ] / B [ 0 ] [ 1 ] / B [ 0 ] [ 2 ]4 / 5 / 1
B [ 1 ] [ 0 ] / B [ 1 ] [ 1 ] / B [ 1 ] [ 2 ]
2 / 8 / 7
B [ 2 ] [ 0 ] / B [ 2 ] [ 1 ] / B [ 2 ] [ 2 ]
9 / 6 / 3
The function should add elements B [ 0] [0 ] ,B [ 0 ] [ 2 ] ,B [ 1 ] [ 1 ],B [ 2 ] [ 0 ] and B [ 2 ] [ 2 ].
e) Evaluate the following postfix notation of expression:(2)
(Show status of Stack after each operation)
True, False, NOT, OR, False, True, OR, AND
ANSWERS
Answer:
a) The function is as follows :
void REASSIGN (int A [ ], intN)
{
for (int i=0;i< n;i++)
{
if(A [ i ] %5 == 0)
A [ i ] =A [ i ] /5;
else
A [ i ] =A [ i ] *2;
}
}
b) Loc(P [ i ] [ j ] )=Base(P) + W(i+j*m)
Loc(P [ i ] [ j ] ) =Base(P) +4(10+40*90)
Loc(P [ 10 ] [ 20 ] )=7200+4(10+40*90)
=7200+4(10+3600)
=7200+4(3610)
=7200+14440
=21640
c) Program:
# include < iostream.h >
# include < stdio.h >
# include < conio.h >
# include < stdlib.h >
# include < ctype.h >
# include < string.h >
Struct node
{
char City [ 20 ] ;
node * link;
} ;
class queue
{
node * front, *rear;
public:
queue () { front = rear = NULL; }
void add_Q; //Add queue
void del_Q; //Delete queue
void show_Q; //Show queue
};
void queue::add_Q()
{
node*temp;
char ct [ 20 ] ;
temp = new node;
cout < “Enter City”;
gets(ct);
strcpy(temp -> City, ct);
temp -> link=NULL;
rear-> link=temp;
rear=temp;
if(front == NULL)
front = rear;
}
// Function for deletion
void queue::del_Q()
{
node *temp;
char ct [ 20 ];
if (front == NULL)
{
cout < ”Queue Empty”;
}
else
{
temp = front;
front = front -> link;
strcpy(ct,temp -> City);
temp -> link=NULL;
cout < ”Delete value is ” < ct;
delete temp;
}
if (front == NULL)
rear = front;
}
//Function for show elements
void queue :: show_Q()
{
Node * temp;
temp = front;
clrscr();
cout < ”The Queue value are”;
while (temp! = NULL)
{
cout < ”n” < temp -> city;
temp= temp -> link;
}
}
void main()
{
node *front,*rear;
int choice;
queue QUEUE;
char opt = ‘Y’;
front = rear = NULL;
clrsrc();
do
{
cout < ”ntt Main Menu”;
cout < ”nt1. Addition of Queue”;
cout < ”nt2. Deletion from Queue”;
cout < ”nt3. Traverse of Queue”;
cout < ”nt4. Exit from Menu”;
cout < ”nn Enter your choice from above”;
cin > choice;
switch (choice)
{
case 1:
do
{
QUEUE.add_Q();
cout < ”nDo you want to add more element < Y/N > ?”;
cin > opt;
}
while(toupper(opt)==’Y’);
break;
case2:
opt =’Y’;
do
{
QUEUE.del_Q();
cout < ”/n Do you want to add more elements < Y/N > ?” ;
cin > opt;
}
while(toupper(opt)==’Y’);
break;
case3:
QUEUE.show_Q();
break;
case 4:
exit(0);
}
}
while (choice ! =4);
}
d)The function is as follows :
int ALTERSUM(int B [ ] [ 5 ] ,int n, int m)
{
int sum=0,q=1;
for(int i=0,i < n; i++)
for(int j=0;j < m; j++)
{
if(q % 2 != 0)
sum = sum+ B [ i ] [ j ] ;
q++;
}
return sum;
}
e)
Element Scanned / StackTrue / True
False / True, False
NOT / True, True
OR / True
False / True ,False
True / True, False, True
OR / True, True
AND / True
So the result is true.
2009
a) Write a function SORTSCORE() in C++ to sort an array of structure Examinee in descending order of Score using Bubble Sort. [3]
Note: Assume the following definition of structure Examinee
struct Examinee
{
long RollNo;
char Name[20];
float Score;
};
Sample Content of the array (before sorting)
1001 / Ravyank Kapur / 300
1005 / Farida Khan / 289
1002 / Anika Jain / 345
1003 / George Peter / 297
Sample Content of the array (after sorting)
Roll No / Name / Score1002 / Anika Jain / 345
1001 / Ravyank Kapur / 300
1003 / George Peter / 297
1005 / Farida Khan / 289
(b) An array T [50][20] is stored in the memory along the column with each of the elements occupying 4 bytes. Find out the base address and address of element T [30][15], if an element T[25][10] is stored at the memory location 9800. [4]
(c) Write a function QUEDEL() in C++ to display and delete element from a dynamically allocated Queue containing nodes the following given structure: [4 ]
struct NODE
{
int Itemno;
char Itemname[20];
NODE *Link;
} ;
d) Define a function SWAPARR() in C++ to swap (interchange) the first row elements with the last row elements, for a dimensional integer array passed as the argument of function. [3]
Example: If the two dimensional array contains
1 / 2 / 4 / 9
2 / 5 / 8 / 1
9 / 7 / 5 / 8
After swapping of the content of first row and last row, it should be as follows:
9 / 7 / 5 / 81 / 2 / 4 / 9
2 / 5 / 8 / 1
5 / 6 / 3 / 2
e) Convert the following infix expression to its equivalent postfix expression showing stack contents for the conversion: [2]
A + B * (C – D) / E
ANSWERS
(a) void SORTSCORE (Examinee E[], int N)
{
Examinee temp;
for ( int i=0; i < N; i++)
for (j=0; j < N-i-1; j++)
if ( E[j]. Score < E[j+1]. Score)
{
temp= E[j];
E[j] = E[j+1];
E[j+1] = temp;
}
}
(b )Given,
W=4
N=50
M=20
Loc(T [25][10])=9800
Column Major Formula:
Loc(T [I][J]) =Base(T)+W*(N*J+I)
Loc(T[25][10]) =Base(T)+4*(50*10+25)
9800 =Base(T)+4*(500+25)
Base(T) =9800- 2100
Base(T) = 7700
Loc(T[30][15]) =7700 +4*(50*15 + 30)
=7700 +4*(750 +30)
=7700 +3120
=10820
(c) #include < iostream.h >
class linkedQueue
{
private :
struct NODE
{
int Itemno;
char Itemname [20];
NODE *Link;
};
NODE *front, *rear;
public :
int remove (void);
}
int linkedQueue:: remove (void)
{
int num;
NODE * temp;
if (front==NULL)
{
cout<” QUEUE EMPTY!! “ ;
return (-1);
}
else
{
temp= front;
front= front ->Link;
num=temp -> Itemno;
delete temp;
if (front==NULL) & (rear=NULL))
return num;
}
}
(d)void SWAPARR ( int X[100] [ ],int M, int N )
{
int temp, i;
for (i=0;i
temp= X [0][i];
X[0][i] = X[N-1][i];
X[N-1][i]= temp;
}
}
(e) A + B * (C – D) / E
symbol scanned / stack / expressionyA
+
B
*
(
C
-
D
)
/
E
) / (
(+
(+
(+ *
(+ * (
(+*(
(+*( -
+*( -
(+*
(+/
(+/ / A
A
A B
A B
A B
A B C
A B C
A B C D
A B C D –
A B C D - *
A B C D - * E
A B C D-* E / +
The equivalent postfix expression is
A B C D - * E / +
2008
a) Write a function in C++, which accepts an integer array and its size as parameters and rearranges the array in reverse. Example: if an array of nine elements initially contains the elements as
4,2,5,6,7,8,12,10
then the function should rearrange the array as
10,12,8,7,6,5,2,[4]
(b) An array Arr[40][10] is stored in the memory along the column with each element occupying 4 bytes. Find the address of the location Arr[3][6], if the location Arr[30][10] is stored at the address 9000. [4]
(c) Write a function in C++ to insert an element into a dynamically allocated Queue where each node contains a name (of type string) as data. [4]
Assume the following definition of THENODE for the same.
struct THENODE
{
char Name[20];
THENODE *LINK;
};
(d) Write a function in C++ to print the product of each column of a two dimensional integer array passed as an argument of the function.
Explain: If the two dimensional array contains. [2]
1 / 2 / 43 / 5 / 6
4 / 3 / 2
2 / 1 / 5
then, the output should appear as:
Product of column 1 = 24
Product of column 2 = 30
Product of column 3 = 240
(e) Evaluate the following postfix notation of expression (Show status of Stack after execution of each operation): [2]
4,10,5,+,*,15,3,/,-
ANSWERS
(a)
# include < iostream.h >
# include < conio.h >
# define n 9
void Reverse(int[], int);
void main()
{
int num[n], i;
cout < "Enter nine elements" < endl;
for ( i=0; i < n;i++)
{
cin > num[i];
}
cout < "Initially the array is:" < endl;
for(i=0; i < n; i++)
{
cout < num[i] < endl;
}
Reverse(num, i-1);
getch();
}
void Reverse(int num[], int i)
{
int index, a, j, temp, k;
index=i;
a=i/2;
if(i%2==1)
a=a+1;
for(k=0;k < a;k++,i--)
{
temp=*(&num[i]);
num[i]=num[k];
*(&num[k])=temp;
}
cout < "After reversing" < endl;
for(j=0; j < = c; j++)
{
cout < num[j] < endl;
}
}
(b) The address of an element a[i][j] is given as:
Address of a[i][j]= Base address + w[n(j-0) + (i-o)]
Here,
Base address is the address of the first element of the array,