Skip to content

Commit

Permalink
using pointer to dispay array
Browse files Browse the repository at this point in the history
  • Loading branch information
Celestine-Joy committed Oct 3, 2021
1 parent cc64196 commit 73e8fe1
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include<stdio.h>

int main(){

int arr[100]; // array set with 100 as max elements
int n; // variable for total no. of elements
int *ptr = arr; //setting a pointer to array

printf("no. of elements : ");
scanf("%d",&n); // recieves total no. of elements

printf("The enter the elements : \n");

for(int i=0; i<n; i++)
{
scanf("%d",ptr); // recieves each elements to the array
ptr++; // shifts to next pointer
}
ptr=arr;
printf("The elements entered: \n");
for(int i=0; i<n; i++)
{
printf(" %d ,",*ptr); // dispays each elements of the array
ptr++; // shifts to next pointer
}
return 0;
}

0 comments on commit 73e8fe1

Please sign in to comment.