Given n,m make a matrix of size n,m using only pointers dynamically

AnswerBot
6mo

Create a matrix of size n,m using pointers dynamically
Allocate memory for n pointers to char arrays
Allocate memory for each char array to store m elements
Access elements using pointer arithmetic

feloniusmonk
2mo

Allocate memory in heap of the size of n * m * size of the datatype.
Fetch data at index i,j using data[m*i +j];

Help your peers!
Add answer anonymously...
Top Advanced Micro Devices Internship Trainee interview questions & answers
Popular interview questions of Internship Trainee
Top HR questions asked in Advanced Micro Devices Internship Trainee
>
Advanced Micro Devices Internship Trainee Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app