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]);
printf("First element of arr using pointer syntax: %d\n", *ptr);
return 0;
__________ __________ ________ _________ __________ _________ ____ ____ __________ ___.
__________ __________ ____ ______ _____ __________ _______ ____ ______ ________.
_____ ______ ______ ________ ________ _____ _______ _________.
___ _________ ______ ____ ______ _______ __________.
______ _________ ____ __________ ___ ____ _____ __________ ________ __________.
_________ _________ ___ ______ ___ ___ _______ ________ ____ ________.
____ ______ ____ __________ ____ ______ _________ _____ ________ _________.
_________ ___ _________ _______ _______ ______ _______ _________.
__________ _______ __________ ____ _________ ________ ____ __________.
__________ _____ _________ ___ ________ ____.
__________ ____ ____ ______ __________ _______ __________ _____ _____ ________.
___ ____ ____ _______ ________ _______ ___ __________ ___ ________ _____.
_______ _______ _____ _____ ____.
___ _______ _____ ___ ______ __________.
____ _________ ______ ________ ________ __________ ___ _______ ________ ______ ____.
______ _____ _______ ____ _________ _______ __________ _________.
___ _____ _____ ________ ___ ____ _________ _________.
______ _______ __________ ___ _________ ________ ________.
_______ ________ ________ ___ __________ ________ _____.
___ ___ ____ ________ _______ __________ _____ __________ ____ ___ _______ ______.
_________ ____ ____ __________ ________ _______ __________ ___ ___ ______.
_________ ________ ____ ____ ________ _____ ____.
____ ____ ____ __________ _______.
_______ ____ _________ ________ _______ _____.
________ ______ ________ ___ ____ _____ ________ __________.
______ ______ _____ ______ _________ _________ _______ ________.
_______ ___ ___ ______ ______ ______ _________.
______ _____ _____ ___ ________ _______ ______ ___ _____.
_____ ____ _______ _____ __________.
_________ ___ ______ ___ _______ _________ __________ _______ _______.
____ ____ ___ _______ ____ _____ __________ ______.
_______ ______ ____ _________ __________ __________ ___ ________ ____ _______ ____ ____.
___ _______ _____ _________ ______ __________ ___ _________ _______ ________.
_____ __________ _________ ____ _________ ___ ____.
__________ _____ ____ ________ _____ ________ ________ ______ _____ _____.
______ ________ _______ __________ __________ ___ _______ _____ _________ ____ ____.
__________.
- Solved Assignments
- Study Notes
- Guess Papers
- Question Papers
✓ Unlock up to 60% of the answer
✓ No payment required