-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathADDRESS_ANY.cpp
More file actions
55 lines (47 loc) · 1.1 KB
/
ADDRESS_ANY.cpp
File metadata and controls
55 lines (47 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//print any row cloumn element address
#include<iostream>
using namespace std;
int main(){
int m,n;
cout<<"Enter the order of Matrix (row and column) :: ";
cin>>m>>n;
int arr[m][n];
cout<<"Enter the elements of matrix :: ";
for(int i = 0;i<m;i++){
for(int j = 0;j<n;j++){
cin>>arr[i][j];
}
}
cout<<"Your matrix is :: "<<endl;
for(int i = 0;i<m;i++){
for(int j = 0;j<n;j++){
cout<<arr[i][j]<<" ";
}
cout<<endl;
}
char ch ;
int h;
cout<<"Enter your Base Address :: ";
cin>>h;
do{
int x = h;
int k,l;
cout<<"\nEnter desired address of particlular element (give row and address) :: ";
cin>>k>>l;
if (k<=m and l<=n){
if(k<l || (k==1 && l==1)){
x += (k*l - 1)*4;
cout<<x<<endl;
}
else{
x += ((k-1)*n + l -1)*4;
cout<<x<<endl;
}
}
else{
cout<<"you enter a wrong pair of row and column \n";
}
cout<<"\nDo you want to check again (y/n) :: ";
cin>>ch;
}while(ch == 'y');
}