18 Jan 2024 Lecture PF - 2D Array and Double Pointers - 2
18 Jan 2024 Lecture PF - 2D Array and Double Pointers - 2
#include <iostream>
#include <cstring>
#include<fstream>
using namespace std;
int a[4][3] = { 0 };
show2DArrayElements(a, 4, 3);
int b[4][3] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
show2DArrayElements(b, 4, 3);
int d[4][3] = { { 10, 20, 30 }, { 40, 50, 60 }, { 70,
80, 90 }, { 100, 110, 120 } };
show2DArrayElements(d, 4, 3);
system("pause");
return 0;
}
#include <iostream>
#include <cstring>
#include<fstream>
using namespace std;
system("pause");
return 0;
}
}
void show2DArrayElements(int arr[4][3], int r, int c)
{
cout << "Showding 2D Array elements" << endl;
#include <iostream>
#include <cstring>
#include<fstream>
using namespace std;
int main() {
int r;
cout << "How many rows you want to create in 2D dynamic
array: ";
cin >> r;
int** dArray = new int* [r]; //5
cout << "How many columns you want o create in each row
of array: ";
int c;
cin >> c;
for (int i = 0; i < r; i++)
{
dArray[i] = new int[c]; // creating rows of size c
}
//
//delete[] dArray;
system("pause");
return 0;
}
delete[] arr[i];
}
delete arr;
}