Question

 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. Also give comments.

27 Apr 2023
Answer :
Word Count : 845

Pointers and arrays have a close relationship in the C programming language. In fact, arrays can be thought of as a kind of pointer.

An array is a contiguous block of memory that stores multiple elements of the same data type. The elements in an array are accessed using an index that represents their position within the array. When an array is declared, the name of the array acts as a constant pointer to the first element of the array.

Pointers, on the other hand, are variables that store memory addresses. They can point to the address of another variable or object. In the case of arrays, a pointer can be used to access elements of the array.

To illustrate the relationship between pointers and arrays, let's consider an example:


#include <stdio.h>

int main() {
    int arr[5] = {1, 2, 3, 4, 5};
    int *ptr = arr; // Assigning the address of the first element to the pointer

    printf("Array elements using array syntax:\n");
    for (int i = 0; i < 5; i++) {
        printf("%d ", arr[i]);
    }

    printf("\nArray elements using pointer syntax:\n");
    for (int i ___ _____ _________ ____ ____ _______ _________ ____.
_________ _______ ___ ___ ________ ____ _____ _________.
______ __________ ________ _________ _______ ____ ____ _________ ____ ____ ______.
______ _______ _________ _______ _______.
___ ___ _________ ____ ______ ___ _____ ___ _______ _______ _________.
_____ _____ ___ ____ ___.
_____ ______ ______ __________ ______ ____ ____ ___.
______ ___ _____ _______ ____ __________ _____.
____ ____ _____ __________ ________ __________ _______ ______ _________ ______ ______.
___ _______ _________ ______ _____ _________ __________ _____ ____ ________ ____.
____ _______ _________ _______ _____ ___ _________ __________ ___ _____ _________.
_________ ______ ______ _________ _________.
_____ ______ __________ _______ ___ ______ _____ _________ _______ _____ __________ _________.
________ ______ _______ _____ ______ _________ _________ _________ ______ _____.
________ __________ ______ ____ ________ ______ __________ ________ ____ _______ _________ _______.
________ _____ ____ ______ ___ ___ ____ ___ ________ _________ ______.
_________ ________ _____ _________ _______ ___ ___ _________ _________ ____ ___.
_______ _______ ____ ________ _________ _________ _________.
________ ______ ____ ___ _________ ______ ____ __________ ________ ______.
_________ _________ ___ ______ _____.
________ __________ _____ ____ ___ ________.
_________ _____ _______ _________ ______ _____ ___.
______ _________ ______ _______ _________ ________ _________ ________ _______ ________ _____ _____.
________ _____ _________ _______ ____ _________ _____.
______ ________ _________ __________ __________ _______ _________ ___ _____ _________ _________.
_______ ______ _____ ________ _________ ____.
________ ___ ____ _____ ______ ___ ______ _________ _____ _______.
_____ __________ ________ ______ _________ _________ __________ ______ _______ _____ ___.
_________ __________ ______ ___ _______ ______.
______ _____ ___ ____ ___ _________ ___ _____ _________.
_______ _______ _____ _______ ___ ___ ___ _____.
___ ________ ___ _____ __________ ________ ________.
__________ _____ __________ __________ __________ ____ __________.
________ ______ ___ ________ _______ ________ _______ _________ __________.
____ ___ ________ _______ _______ ________ ______ _______ _______ __________ ______ _______.
_______ _______ ________ _______ ________ _____ ____ _______ _______ ___ ____ ____.
_____ ___ __________ _______ ________ ________ ________.
_________ _________ ____ __________ ________ _________ ________ ____ _________.
_________ __________ ________ _____ ___ ____ ____.
___ ____ _________ ______ ________ ___ ______ _____ ___ __________.
_________ __________ ________ _______ __________ _____ _________ __________.
__________ _____ __________ __________ _______ _____ ___ ___.
_________ _________ _________ ___ ____.
____ _______ _____ __________ ________ ________ _________ ______.
_____ _________ ______ _____ __________ ______.
___ _______ _________ ___ _________.
_________ __________ __________ ___ _________ ________ ______ __________ ________ _________.
__________ _________ ___ __________ ____ _______ ______ __________ ____.
________ _______ ________ ________ ___ ___ _______ ________.
______ ____ __________ ________ _____ _____ __________ _______ ___ _____ ___ ___.
__________ ______ _________ ___ ______ __________ _____ ______ _____ ________.
______ _____ __________ ____ _____ __________ _______ _____.
________ ___ ________ ______ _________ _________ ____ _____ _________ ______.
_____ _________ ___ _________ _____ _______ _______.
_____ __________ ________ ___ _____ _________.
__________ ______ ___ ______ ______.
____ _____ ________ ________ _______ ______ __________ ______ ______ ____ ___ _______.
____ _____ ________ __________ ___ ___ _______ __________.
_____ _____ ________ _________ ______ ____ ___ _______ ________.
_____ ____ __________ ____ ___ ___ _________ ________.
__________ __________ _________ ___ _____ _______.
_________ ________ ________ ____ _______.
_____ ___ _____ ________ _______.
____ ______ _____ ________ ______ __________ ____ _____ _______.
________ ___ ________ ____ _____ _____.
_____ __________ _________ ________ __________ _________ _________ ________ __________.
____ ________ ___ ___ ____ __________ ________ ______ _________ ________ ____.
________ _______ ____ _________ ____ __________.
________ _______ ___ _____ _____ ________ ______ ___ _______ ________ ______ _____.
_______ _____ _______ ________ __________ _______ ______.
______ ______ ____ _____ _______ __________.
_____ ________ __________ __________ _____ __________ _____ __________ ________ _____ ______.
________ ________ __________ _______ ___ _________.
___ ___ ______ ________ ___ ________ ____ __________ __________ ___.
____ _________ ________ ______ _______ ______ _______ __________.
______ ____ ___.
Get Full Answer on WhatsApp

IGNOU NEWS
Assignment Submission Last Date Extended Till 30 June 2026 Click Here★★★IGNOU June 2026 TEE Date Sheet Released Click Here★★★
Top
📞
Call Support Instant phone assistance  Briefly discuss the relation between pointers and arrays, giving
🟢
WhatsApp Chat Fast live messaging
Email Us Business enquiries & support