Program to print array using pointer

Write a program to print the array using the pointer

Example:

Input:  arr[]={4,3,5,2,1}
Output: 4 3 5 2 1

Approach

C

#include <stdio.h>
int main()
{
    int arr[] = {43521};
    int n = sizeof(arr) / sizeof(arr[0]);
    for (int i = 0i < ni++)
    {
        printf("%d ", *(arr + i));
    }
    return 0;
}


No comments:

Post a Comment