Let's try defining the size of the array and create the contents of it on our own! And then, to give off a sense of excitement, let's try accessing the value of an array element in a random index position!
#include <stdio.h>
int main()
{
int n;
int arr[]={5,7,12,9,10,15};
printf("Enter the index of the element to access: ");
scanf("%d",&n);
printf("Element at index %d",n);
printf(" is %d",arr[n]);
return 0;
}
Comments
Leave a comment