181k views
0 votes
. The variable numbers is a 2-dimensional array of type int; output all of its elements that are strictly greater than 10

1 Answer

4 votes

Answer:

// here is code in c++.

#include <bits/stdc++.h>

using namespace std;

int main()

{

// variable to read row and column of 2-d array

int r,c;

cout<<"enter the number of row:";

// read number of row

cin>>r;

cout<<"enter the number of column:";

// read number of column

cin>>c;

// create an array of size rxc

int arr[r][c];

cout<<"enter the elements of the array:"<<endl;

// read the elements of 2-d array

for(int i=0;i<r;i++)

{

for(int j=0;j<c;j++)

{

cin>>arr[i][j];

}

}

cout<<"numbers which are greater than 10 in 2-d array"<<endl;

for(int i=0;i<r;i++)

{

for(int j=0;j<c;j++)

{

// if element is greater than 10, print it

if(arr[i][j]>10)

cout<<arr[i][j]<<" ";

}

cout<<endl;

}

return 0;

}

Step-by-step explanation:

Read the size of 2-d array i.e row and column.Create a 2-d array of size rxc of integer type.Read the elements of the array. Then traverse the array and if an element if greater than 10 then print that element.

Output:

enter the number of row:3

enter the number of column:3

enter the elements of the array:

23 45 53 78 1 9 6 8 77

numbers which are greater than 10 in 2-d array

23 45 53

78

77

User Genoil
by
6.3k points