Briefly discuss the relation between Pointers and Arrays, giving suitable example. Write a program in C, to print transpose of a 2D matrix entered by a user. Support your program with suitable comments.
Pointers and arrays have a close relationship in C programming, as arrays can be accessed using pointers and vice versa. In C, an array name often behaves like a pointer to the first element of the array. When you use the array name, it gets converted into a pointer to the first element.
Consider the following example:
```c
#include <stdio.h>
int main() {
int arr[3] = {1, 2, 3};
int *ptr = arr; // ptr points to the first element of arr
printf("First element of arr using array syntax: %d\n", arr[0]);
__________ _____ ______ _________ __________ _________ _____.
___ _____ __________ _____ ____ _____ _______ ______ _________ _______ ____.
__________ ________ _______ __________ __________ _________ _________ __________ _____ ____ ___ ________.
___ __________ __________ _____ _____.
_____ ________ _______ _______ __________ ____ ___.
______ ___ __________ ___ ___ _________.
__________ _________ _______ ________ __________ ______ ______ ____ ________ _________ _____.
____ ________ ______ ____ _______ _____ __________ ______.
_________ _________ ______ _____ _____ ___ ________ ___.
________ _______ ______ ____ _______.
_________ ___ ________ ____ _________ __________ _________ _________ _____ ______ _______ _________.
________ _____ __________ _____ _________ __________ __________.
_________ ________ ___ ________ _________.
__________ _____ _____ ______ _____ __________.
_________ ___ ______ _____ ______.
______ ____ _______ _______ __________ __________ ________ ________ __________ _________.
_______ ____ _______ __________ ____ _____ _____ _______.
_________ ______ ___ __________ _____ ________ ____ _____ ___ ______.
____ _________ __________ _____ _______ ______ ___.
____ ______ ___ ____ ______ __________ _________ ________ ____.
__________ ________ ______ _____ ___ ___ ______.
________ _______ _______ ________ __________.
____ ______ ___ _____ _______.
________ ___ ____ ____ ___ _____ ____.
_________ ______ ___ __________ ___ _______ ___ _______ ________ __________ __________.
____ __________ ______ __________ ________ __________ _____ ________ __________.
__________ ______ ___ _________ _________ _____ ___.
____ _____ ______ ___ _______ ___ ________ __________ ______.
______ ___ _________ _____ _______ ____.
________ ______ _______ ____ ___ _______.
_____ __________ _____ ____ _______.
_______ _________ _________ _________ _______ ____.
__________ __________ __________ _______ _________ ________ ____.
____ __________ __________ _________ _______ ____ _________ ____ _____.
__________ __________ ____ _______ ____ ______ ______ _________ ____ ____.
_________ __________ _________ _________ ____ _____ _________ _______.
_________ __________ _________ __________ _________ ____ ______ __________ ___ ______ ____ ___.
_________ _________ ___ ______ _________ ___ ______ ______ ____ _______ ____ _____.
__________ ____ _________ ____ ______ ___ _____ ___ ____.
____ ___ _________ ________ ___ __________ ___ _________.
________ __________ ________ __________ _____.
Get Full Answer on WhatsApp