0% found this document useful (0 votes)
21 views1 page

Pointer-Based Array Manipulation

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views1 page

Pointer-Based Array Manipulation

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

ARRAY MANIPULATION USING POINTER

#include <stdio.h>

main()

int arr[] = {10, 20, 30, 40, 50};

int *ptr;

ptr = arr;

printf("Array elements using pointer:\n");

for(int i = 0; i < 5; i++)

printf("Element at index %d: %d\n", i, *(ptr + i));

*(ptr + 2) = 100;

*(ptr + 4) = 200;

printf("\n Modified array elements:\n");

for(int i = 0; i < 5; i++)

printf("Element at index %d: %d\n", i, *(ptr + i));

You might also like