Arrays on Data Structure and Algorithms related Questions and Answers


Question :   How do you allocate a matrix using a single pointer in C?(r and c are the number of rows and columns respectively)
1. int *arr = malloc(r * c * sizeof(int));
2. int *arr = (int *)malloc(r * c * sizeof(int));
3. int *arr = (int *)malloc(r + c * sizeof(int));
4. int *arr = (int *)malloc(r * c * sizeof(arr));
Answer :   2 - int *arr = (int *)malloc(r * c * sizeof(int));  

* Be the First to Post a Comment.

Submit comment :


Captcha Image
Reload

Ask Question

Captcha Image
Reload

Note : Name and Email never shown.





Subscribe


Become a part of EducationForever. Subscribe to our FREE Newsletter