In: Computer Science
Write a program on C defining an array. Find the element at given index k. Replace the element at given index k.
#include
int main()
{
int arr[5] = {1, 2, 3, 4, 5};
int index;
printf("Enter the index number(0-4): ");
scanf("%d", &index);
printf("Element at index %d is %d\n", index, arr[index]);
arr[index] = 10;
printf("After replacing the element at index %d is %d\n", index, arr[index]);
return 0;
}
===============================================================
Sample Output: