That doesn't make any sense. arr
is an array so the concept of 'incrementing' it doesn't exist. You can increment a variable used as a pointer to the current element, but you're 99% of the way there already with i
. Just prompt for a temporary value and then insert that into the array at location 'i':
for (int i = 0; i < 3; i++)
{
printf("Enter the value of element %d\n", (i));
scanf("%d", value); // Get new value
arr[i] = value; // store value in current element
}
(Sorry - my C is rusty but I hope you can see what I'm getting at).
I also changed your prompt to use i
rather than i+1
. c arrays start from 0 and 'i' has values from 0 to 2 which correlate to the element indices. You may not like arrays starting at 0, but they just do, because it's not the element 'number' but rather the 'offset' from the beginning of the array (this may help you understand why they start at 0).
It's confusing to ask for the value for element '1' (for example) when you are actually asking for a value for element 0.