Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The end-of-array dilemma Write a program that defines an array of type integer.

ID: 3565492 • Letter: T

Question

The end-of-array dilemma Write a program that defines an array of type integer. Print out the array elements and go deliberately ??beyond?? the end of the array. i.e. read/output array elements with indexes that are not accomodated by the array definition. Now extend your program to continuously write beyond the end of the array. Output the indeces of the elements that you mote and check, how many elements you can get away with writing at illegimate locations. What are your conclusions of what you see?

Explanation / Answer

#include<stdio.h>

int main()

{

int i;

int arr[5];

   for (i=0;i<100;i++){

       arr[i] = i+1000;

   }

for (i=0;i<100;i++)

{

printf("value of arr[%d] is %d ", i, arr[i]);

}

}

Able to change the value of all the elements that are there beyond the array. There is no issue accessing the elements beyond the array limit.

Conclusion: There is no Array bound check in C language.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote