Create a free account on Computer Sir Ki Class and unlock access to valuable learning resources.
Exam Paper Downloads: After registering and logging in, you can download exam question papers in PDF format to practice and prepare for your exams.
Student Support: Get assistance with your doubts, queries, and questions related to your studies. Our support is here to help you understand topics and resolve your learning difficulties.
Register today and make your exam preparation easier and more effective!
Write definition for a function DISPMID(int A[][5],int R,int C) in C++ to display the elements of middle row and middle column from a two dimensional array A having R number of rows and C number of columns.
For example, if the content of array is as follows:
215
912
516
401
515
103
901
921
802
601
285
209
609
360
172
The function should display the following as output
103 901 921 802 601
516 921 609
Answer:
void DISPMID(int A[][5],int R,int C)
{
for (int J=0;J<C;J++)
cout<<A[R/2][J]<< β β;
cout<<endl;
for (int I=0;I<R;I++)
cout<<A[I][C/2]<< β β;
}
OR
void DISPMID(int A[][5],int R,int C)
{
if(R%2!=0)
{
for (int J=0;J<C;J++)
cout<<A[R/2][J]<< β β;
}
else
cout<<βNo Middle Rowβ;
cout<<endl;
if(C%2!=0)
{
for (int I=0;I<R;I++)
cout<<A[I][C/2]<< β β;
}
else
cout<<βNo Middle ColumnβΝΎ
}
OR
Any other correct equivalent function definition
C. Sir| Created: 1-Jan-2019 | Updated: 22-Mar-2026|CBSE12A-2016