How toprint increment matrix if first element is 1
Answers
Answered by
2
Answer:#include <stdio.h>
void incrementArray(int[]);
void main()
{
int i;
int array[4] = {10, 20, 30, 40};
incrementArray(array);
for (i = 0; i < 4; i++)
printf("%d\t", array[i]); // Prints 2, 3, 4, 5
}
void incrementArray(int arr[])
{
int i;
for (i = 0; i < 4; i++)
arr[i]++;
}
Explanation:
Answered by
1
Answer:
Explanation:
You can access the element here using *p . This is different from Java where you would have to use an integer index variable to access elements of an array. Incrementing a pointer in C++ where that pointer does not point to an element of an array is undefined behaviour.
Similar questions