Explanation: A pointer in C is a variable that stores the memory address of another variable. It allows direct manipulation of memory and is a powerful feature for tasks like dynamic memory allocation.
Explanation: To declare a pointer in C, you use the syntax datatype *ptr; where datatype is the type of variable the pointer will point to.
Explanation: In C, the ‘&’ operator is the address-of operator. It returns the memory address of the variable it’s applied to.
int main() {
int num = 10;
int *ptr = #
printf("%d", *ptr);
return 0;
}
Explanation: This code snippet declares an integer variable ‘num’, initializes it to 10, and then declares a pointer ‘ptr’ pointing to the address of ‘num’. The printf statement prints the value pointed to by ‘ptr’, which is 10.
Explanation: Dereferencing a null pointer in C results in undefined behavior, often leading to a segmentation fault and program termination.
Explanation: To dynamically allocate memory for an integer in C, you use the malloc function, specifying the size of the data type in bytes.
Explanation: Pointer arithmetic in C involves adding or subtracting integers to pointers to navigate through memory or arrays.
Explanation: The size of a pointer variable in C depends on the architecture and compiler being used.
Explanation: A null pointer in C is a pointer that does not point to any memory location.
Explanation: The ‘void’ pointer in C is a generic pointer type that can be used to point to objects of any data type. It cannot be dereferenced directly.
int arr[] = {10, 20, 30, 40, 50};
int *ptr = arr;
printf("%d", *(ptr + 2));
Explanation: The expression *(ptr + 2) calculates the address of the third element in the array ‘arr’ (since pointer arithmetic automatically accounts for the size of the data type), which is 30.
Explanation: Pointer arithmetic in C allows adding or subtracting integers to pointers, enabling navigation through memory or arrays.
int main() {
int arr[] = {1, 2, 3, 4, 5};
int *ptr = arr;
printf("%d", *(ptr++));
printf("%d", *(++ptr));
return 0;
}
Explanation: The expression *(ptr++) first prints the value at ‘ptr’ (which is 1) and then increments ‘ptr’. The expression *(++ptr) then prints the value at the next position after the increment, which is 3.
Explanation: Pointer subtraction in C returns the number of elements between the two memory addresses, taking into account the size of the data type.
Explanation: Pointer arithmetic in C can be applied to any pointer, not just those pointing to arrays.
int main() {
int arr[] = {10, 20, 30, 40, 50};
int *ptr = arr + 2;
printf("%d", *ptr);
return 0;
}
What will be the output of this code?Explanation: The pointer ‘ptr’ is initialized to point to the third element of the array ‘arr’ (30), as pointer arithmetic adds the size of the data type (int) multiplied by 2 to ‘arr’.
char str[] = "Hello";
char *ptr = str + 2;
printf("%c", *ptr);
Explanation: The pointer ‘ptr’ is initialized to point to the third character of the string “Hello” (index 2), which is ‘l’.
Explanation: Pointer arithmetic with void pointers is allowed in C, but because void pointers have no associated data type, the size of the data type must be explicitly specified.
Explanation: In C, there are no runtime bounds checking for array accesses, so performing pointer arithmetic beyond the bounds of an array leads to unpredictable behavior.
int main() {
int arr[] = {1, 2, 3, 4, 5};
int *ptr1 = arr + 1;
int *ptr2 = arr + 3;
printf("%d", ptr2 - ptr1);
return 0;
}
Explanation: Pointer subtraction in C returns the number of elements between the two memory addresses. Here, ptr2 points to the fourth element and ptr1 points to the second element, so the difference is 1.
Explanation: In C, when an array is passed to a function, it decays into a pointer to its first element.
Explanation: When an array decays into a pointer in C, it is automatically converted into a pointer to its first element.
int arr[5] = {1, 2, 3, 4, 5};
int *ptr = arr;
What does ‘ptr’ point to?Explanation: ‘ptr’ points to the first element of the ‘arr’ array.
Explanation: In C, array indexing starts from 0, so the third element is accessed using the index 2.
Explanation: Arrays decay into pointers when passed to functions, so passing a pointer to the first element effectively passes the entire array.
int arr[5] = {1, 2, 3, 4, 5};
int *ptr = arr;
printf("%d", *(ptr + 3));
What will be the output of this code?Explanation: *(ptr + 3) accesses the fourth element of the ‘arr’ array, which is 4.
int main() {
int arr[] = {1, 2, 3, 4, 5};
printf("%d", *arr);
return 0;
}
Explanation: *arr dereferences the pointer to the first element of the ‘arr’ array, which is 1.
Explanation: While arrays decay into pointers in certain contexts, pointers and arrays have different properties and behaviors in C.
Explanation: sizeof operator returns the size of the entire array in bytes, so dividing by the size of each element gives the number of elements.
int arr[5] = {1, 2, 3, 4, 5};
int *ptr = &arr[2];
printf("%d", *(ptr - 1));
What will be the output of this code?Explanation: *(ptr – 1) accesses the element before the one pointed to by ‘ptr’, which is 2.
Explanation: Arrays in C are fixed and cannot be reassigned to point to different memory locations after initialization.
int arr[5] = {1, 2, 3, 4, 5};
int *ptr = arr;
printf("%d", ptr[2]);
What will be the output of this code?Explanation: ptr[2] accesses the third element of the ‘arr’ array through pointer notation, which is 3.
Explanation: When using the subscript operator ([]), arrays and pointers are interchangeable in C.
int arr[] = {1, 2, 3, 4, 5};
int *ptr = &arr[0];
printf("%d", ptr[4]);
What will be the output of this code?Explanation: ptr[4] accesses the fifth element of the ‘arr’ array through pointer notation, which is 5.
Explanation: In C, arr[i] and *(arr + i) are equivalent and both access the element at index ‘i’ of the array ‘arr’.
int arr[5] = {1, 2, 3, 4, 5};
int *ptr = arr;
printf("%d", *(ptr + 4));
What will be the output of this code?Explanation: *(ptr + 4) accesses the fifth element of the ‘arr’ array through pointer arithmetic, which is 5.
Explanation: In C, arrays of pointers can be created as long as the pointers are of the same data type.
int *ptr;
int arr[] = {1, 2, 3, 4, 5};
ptr = arr;
printf("%d", *ptr);
What will be the output of this code?Explanation: *ptr accesses the value of the first element of the ‘arr’ array, which is 1.
char *ptr = "Hello";
printf("%c", *(ptr + 2));
Explanation: *(ptr + 2) accesses the third character of the string “Hello”, which is ‘l’.
Explanation: In C, the name of an array can be used as a pointer to its first element in most contexts.
Explanation: In C, strings are typically represented as arrays of characters, terminated by a null character (‘\0’).
Explanation: A null-terminated string in C is a sequence of characters followed by a null character (‘\0’).
char str[] = "Hello";
char *ptr = str;
What does ‘ptr’ point to?Explanation: ‘ptr’ points to the first character of the ‘str’ string.
char str[] = "Hello";
char *ptr = str;
printf("%c", *ptr);
Explanation: *ptr accesses the value of the first character of the ‘str’ string, which is ‘H’.
char str[] = "Hello";
printf("%c", str[4]);
Explanation: str[4] accesses the fifth character of the ‘str’ string, which is ‘o’.
char str[] = "Hello";
char *ptr = str;
printf("%s", ptr);
What will be the output of this code?Explanation: ‘%s’ format specifier in printf is used to print a null-terminated string, so it prints the entire ‘str’ string.
Explanation: Modifying a string literal in C leads to undefined behavior, as string literals are typically stored in read-only memory.
char *str = "Hello";
printf("%c", *(str + 4));
What will be the output of this code?Explanation: *(str + 4) accesses the fifth character of the string “Hello”, which is ‘o’.
char str[] = "Hello";
char *ptr = str;
ptr += 2;
printf("%c", *ptr);
Explanation: ‘ptr += 2;’ moves the pointer ‘ptr’ two positions forward in the ‘str’ string, so ‘*ptr’ now points to ‘l’.
Explanation: The ‘strcmp’ function in C is used to compare two strings lexically.
Explanation: The ‘strcpy’ function in C is used to copy the contents of one string to another.
char str1[] = "Hello";
char str2[10];
strcpy(str2, str1);
printf("%s", str2);
Explanation: This code copies the content of ‘str1’ to ‘str2’ using ‘strcpy’ and then prints ‘str2’, which contains “Hello”.
Explanation: The ‘strcat’ function in C is used to concatenate (append) one string to the end of another.
char str1[] = "Hello";
char str2[] = ", world!";
strcat(str1, str2);
printf("%s", str1);
Explanation: This code concatenates ‘str2’ to the end of ‘str1’ using ‘strcat’, resulting in “Hello, world!”.
Explanation: The ‘strlen’ function in C is used to determine the length of a string (the number of characters before the null terminator).
char str[] = "Hello";
int length = strlen(str);
printf("%d", length);
Explanation: ‘strlen’ returns the length of the string excluding the null terminator, so the length of “Hello” is 5.
Explanation: The ‘strncpy’ function in C is used to copy characters from one string to another with a specified maximum length.
char str1[] = "Hello";
char str2[10];
strncpy(str2, str1, 3);
str2[3] = '\0';
printf("%s", str2);
What will be the output of this code?Explanation: ‘strncpy’ copies the first 3 characters of ‘str1’ to ‘str2’, and then ‘\0’ is added manually to terminate the string.
Explanation: The ‘strncat’ function in C is used to concatenate (append) a specified number of characters from one string to another.
char str1[] = "Hello";
char str2[] = ", world!";
strncat(str1, str2, 5);
printf("%s", str1);
What will be the output of this code?Explanation: ‘strncat’ appends the first 5 characters of ‘str2’ to ‘str1’, resulting in “Hello, w”.
Explanation: A pointer to a pointer in C holds the address of another pointer.
int num = 10;
int *ptr = #
int **ptr_to_ptr = &ptr;
What does ‘ptr_to_ptr’ point to?Explanation: ‘ptr_to_ptr’ holds the address of ‘ptr’.
int num = 10;
int *ptr = #
int **ptr_to_ptr = &ptr;
printf("%d", **ptr_to_ptr);
Explanation: **ptr_to_ptr dereferences the pointer twice, accessing the value pointed to by ‘ptr’, which is 10.
Explanation: Pointers to pointers are commonly used to create and manipulate multi-dimensional arrays dynamically.
int num = 10;
int *ptr = #
int **ptr_to_ptr = &ptr;
**ptr_to_ptr = 20;
printf("%d", num);
What will be the output of this code?Explanation: **ptr_to_ptr modifies the value pointed to by ‘ptr’ indirectly, so ‘num’ becomes 20.
int arr[] = {1, 2, 3, 4, 5};
int *ptr = arr;
int **ptr_to_ptr = &ptr;
printf("%d", *(*ptr_to_ptr + 2));
Explanation: *(*ptr_to_ptr + 2) accesses the third element of the ‘arr’ array through pointer notation, which is 3.
int arr[] = {1, 2, 3, 4, 5};
int *ptr = arr;
int **ptr_to_ptr = &ptr;
*ptr_to_ptr += 2;
printf("%d", **ptr_to_ptr);
What will be the output of this code?Explanation: *ptr_to_ptr += 2 moves the pointer ‘ptr’ two positions forward in the ‘arr’ array, so **ptr_to_ptr now points to 3.
Explanation: Passing a pointer to a pointer allows a function to modify the original pointer itself, not just the value it points to.
void changePtr(int **ptr) {
int num = 20;
*ptr = #
}
int main() {
int num = 10;
int *ptr = #
changePtr(&ptr);
printf("%d", *ptr);
return 0;
}
Explanation: The ‘changePtr’ function modifies the pointer ‘ptr’ to point to the local variable ‘num’, so the output is 20.
Explanation: Double pointers are commonly used to create and manipulate multi-dimensional arrays, especially dynamically allocated ones.
Explanation: A double pointer in C is declared with two asterisks, such as int **ptr;.
int arr[] = {1, 2, 3, 4, 5};
int *ptr = arr;
int **ptr_to_ptr = &ptr;
printf("%d", **ptr_to_ptr);
What will be the output of this code?Explanation: **ptr_to_ptr dereferences the pointer twice, accessing the value pointed to by ‘ptr’, which is the first element of ‘arr’ (1).
Explanation: Using a double pointer as a function argument allows the function to modify the original pointer, not just the value it points to.
void modifyPtr(int **ptr) {
int num = 20;
*ptr = #
}
int main() {
int num = 10;
int *ptr = #
modifyPtr(&ptr);
printf("%d", *ptr);
return 0;
}
What will be the output of this code?Explanation: The ‘modifyPtr’ function modifies the pointer ‘ptr’ to point to the local variable ‘num’, so the output is 20.
int num1 = 10, num2 = 20;
int *ptr1 = &num1, *ptr2 = &num2;
int **ptr_to_ptr = &ptr1;
*ptr_to_ptr = ptr2;
printf("%d", **ptr_to_ptr);
Explanation: *ptr_to_ptr = ptr2; modifies ‘ptr1’ to point to ‘num2’, so **ptr_to_ptr will print the value of ‘num2’.
int num1 = 10, num2 = 20;
int *ptr1 = &num1, *ptr2 = &num2;
int **ptr_to_ptr = &ptr1;
**ptr_to_ptr += 5;
printf("%d", *ptr1);
Explanation: **ptr_to_ptr += 5; increments the value pointed to by ‘ptr1’ by 5, so *ptr1 will be 15.
int num1 = 10, num2 = 20;
int *ptr1 = &num1, *ptr2 = &num2;
int **ptr_to_ptr = &ptr1;
*ptr_to_ptr += 2;
printf("%d", **ptr_to_ptr);
What will be the output of this code?Explanation: Incrementing a double pointer like ‘*ptr_to_ptr += 2;’ is not allowed in C.
int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
int **ptr = (int **)arr;
printf("%d", *(*(ptr + 1) + 1));
Explanation: *(ptr + 1) moves to the second row, and then +1 moves to the second column of that row, accessing 4.
int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
int **ptr = (int **)arr;
printf("%d", *(*(ptr + 2) + 1));
What will be the output of this code?Explanation: *(ptr + 2) moves to the third row, and then +1 moves to the second column of that row, accessing 8.
int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
int **ptr = (int **)arr;
printf("%d", *(*(ptr + 1) + 2));
Explanation: *(ptr + 1) moves to the second row, and then +2 moves to the third column of that row, accessing 6.
Explanation: A function pointer in C holds the address of a function.
Explanation: The syntax for declaring a function pointer is return_type (*ptr)(parameters).
void greet() {
printf("Hello, world!");
}
int main() {
void (*ptr)();
ptr = &greet;
ptr();
return 0;
}
What will be the output of this code?Explanation: The function pointer ‘ptr’ is assigned the address of the ‘greet’ function, which is then called.
Explanation: Function pointers in C allow passing the address of a function as an argument or return value.
int add(int a, int b) {
return a + b;
}
int main() {
int (*ptr)(int, int);
ptr = &add;
printf("%d", ptr(3, 4));
return 0;
}
What will be the output of this code?Explanation: The function pointer ‘ptr’ is assigned the address of the ‘add’ function, which is then called with arguments 3 and 4.
void printHello() {
printf("Hello");
}
void printWorld() {
printf(", world!");
}
int main() {
void (*ptr)();
ptr = &printHello;
ptr();
ptr = &printWorld;
ptr();
return 0;
}
Explanation: The function pointer ‘ptr’ is first assigned the address of ‘printHello’ and then ‘printWorld’, resulting in both functions being called.
Explanation: An array of function pointers allows selecting and calling different functions based on runtime conditions.
int add(int a, int b) {
return a + b;
}
int subtract(int a, int b) {
return a - b;
}
int main() {
int (*ptr[2])(int, int) = {&add, &subtract};
printf("%d", ptr[1](5, 3));
return 0;
}
What will be the output of this code?Explanation: ‘ptr[1](5, 3)’ calls the ‘subtract’ function, resulting in 5 – 3 = 2.
void printNumber(int num) {
printf("%d", num);
}
void printChar(char ch) {
printf("%c", ch);
}
int main() {
void (*ptr[2])(int) = {&printNumber, &printChar};
ptr ;
ptr[1]('A');
return 0;
}
Explanation: ‘ptr ‘ calls ‘printNumber’ with argument 5, and ‘ptr[1](‘A’)’ calls ‘printChar’ with argument ‘A’.
void multiply(int a, int b) {
printf("%d", a * b);
}
void divide(int a, int b) {
printf("%d", a / b);
}
int main() {
void (*ptr[2])(int, int) = {&multiply, ÷};
ptr[1](10, 5);
return 0;
}
Explanation: ‘ptr[1](10, 5)’ calls ‘divide’ with arguments 10 and 5, resulting in 10 / 5 = 2.
void printSquare(int num) {
printf("%d", num * num);
}
void printCube(int num) {
printf("%d", num * num * num);
}
int main() {
void (*ptr[2])(int) = {&printSquare, &printCube};
ptr ;
ptr ;
return 0;
}
Explanation: ‘ptr ‘ calls ‘printSquare’ with argument 3, and ‘ptr ‘ calls ‘printCube’ with argument 3.
void addOne(int *num) {
(*num)++;
}
void subtractOne(int *num) {
(*num)--;
}
int main() {
int num = 5;
void (*ptr[2])(int *) = {&addOne, &subtractOne};
ptr[0](&num);
ptr[1](&num);
printf("%d", num);
return 0;
}
Explanation: ‘ptr[0](&num)’ calls ‘addOne’ with the address of ‘num’, and ‘ptr[1](&num)’ calls ‘subtractOne’ with the address of ‘num’. The value of ‘num’ remains 5.
void doubleValue(int *ptr) {
*ptr *= 2;
}
void halveValue(int *ptr) {
*ptr /= 2;
}
int main() {
int num = 10;
void (*ptr[2])(int *) = {&doubleValue, &halveValue};
ptr[0](&num);
ptr[1](&num);
printf("%d", num);
return 0;
}
Explanation: ‘ptr[0](&num)’ doubles the value of ‘num’, and ‘ptr[1](&num)’ halves the value of ‘num’. The value of ‘num’ remains 10.
void increment(int *ptr) {
(*ptr)++;
}
void decrement(int *ptr) {
(*ptr)--;
}
int main() {
int arr[] = {1, 2, 3, 4, 5};
void (*ptr[2])(int *) = {&increment, &decrement};
ptr[0](arr + 2);
ptr[1](arr + 1);
printf("%d", arr[3]);
return 0;
}
Explanation: ‘ptr[0](arr + 2)’ increments the value at index 2 of ‘arr’, and ‘ptr[1](arr + 1)’ decrements the value at index 1 of ‘arr’. So, arr[3] becomes 4.
void addTwo(int *ptr) {
(*ptr) += 2;
}
void subtractThree(int *ptr) {
(*ptr) -= 3;
}
int main() {
int num = 10;
void (*ptr[2])(int *) = {&addTwo, &subtractThree};
ptr[0](&num);
ptr[1](&num);
printf("%d", num);
return 0;
}
Explanation: ‘ptr[0](&num)’ adds 2 to ‘num’, and ‘ptr[1](&num)’ subtracts 3 from ‘num’. So, the final value of ‘num’ is 9.
void addFive(int *ptr) {
(*ptr) += 5;
}
void subtractTen(int *ptr) {
(*ptr) -= 10;
}
int main() {
int num = 20;
void (*ptr[2])(int *) = {&addFive, &subtractTen};
ptr[1](&num);
ptr[0](&num);
printf("%d", num);
return 0;
}
Explanation: ‘ptr[1](&num)’ subtracts 10 from ‘num’, and ‘ptr[0](&num)’ adds 5 to the result. So, the final value of ‘num’ is 15.
Explanation: Pointers allow functions to modify the values of arguments passed to them directly.
void swap(int *a, int *b) {
int temp = *a;
*a = *b;
*b = temp;
}
int main() {
int x = 5, y = 10;
printf("Before swap: x = %d, y = %d\n", x, y);
swap(&x, &y);
printf("After swap: x = %d, y = %d\n", x, y);
return 0;
}
What will be the output of this code?Explanation: The ‘swap’ function exchanges the values of ‘x’ and ‘y’ using pointers.
void modify(int *ptr) {
(*ptr)++;
}
int main() {
int num = 5;
printf("Before modification: %d\n", num);
modify(&num);
printf("After modification: %d\n", num);
return 0;
}
Explanation: The ‘modify’ function increments the value of ‘num’ using a pointer.
void change(int *ptr) {
*ptr = 100;
}
int main() {
int num = 50;
change(&num);
printf("%d", num);
return 0;
}
Explanation: The ‘change’ function modifies the value of ‘num’ to 100 using a pointer.
void update(int *ptr) {
(*ptr) += 50;
}
int main() {
int num = 100;
update(&num);
printf("%d", num);
return 0;
}
Explanation: The ‘update’ function adds 50 to the value of ‘num’ using a pointer.
void increment(int *ptr) {
*ptr = *ptr + 1;
}
int main() {
int num = 5;
increment(&num);
printf("%d", num);
return 0;
}
Explanation: The ‘increment’ function increases the value of ‘num’ by 1 using a pointer.
void changeValue(int *ptr) {
(*ptr) -= 10;
}
int main() {
int num = 50;
changeValue(&num);
printf("%d", num);
return 0;
}
Explanation: The ‘changeValue’ function subtracts 10 from the value of ‘num’ using a pointer.
void modifyArray(int *arr, int size) {
for (int i = 0; i < size; i++) {
arr[i] += 10;
}
}
int main() {
int array[] = {1, 2, 3, 4, 5};
modifyArray(array, 5);
for (int i = 0; i < 5; i++) {
printf("%d ", array[i]);
}
return 0;
}
Explanation: The 'modifyArray' function adds 10 to each element of the array.
void updateArray(int *arr, int size) {
for (int i = 0; i < size; i++) {
arr[i] *= 2;
}
}
int main() {
int array[] = {1, 2, 3, 4, 5};
updateArray(array, 5);
for (int i = 0; i < 5; i++) {
printf("%d ", array[i]);
}
return 0;
}
Explanation: The 'updateArray' function multiplies each element of the array by 2.
void changeArray(int *arr, int size) {
for (int i = 0; i < size; i++) {
arr[i] -= i;
}
}
int main() {
int array[] = {5, 7, 9, 11, 13};
changeArray(array, 5);
for (int i = 0; i < 5; i++) {
printf("%d ", array[i]);
}
return 0;
}
Explanation: The 'changeArray' function subtracts the index from each element of the array.
void modifyValues(int *arr, int size) {
for (int i = 0; i < size; i++) {
arr[i] += i * i;
}
}
int main() {
int array[] = {1, 2, 3, 4, 5};
modifyValues(array, 5);
for (int i = 0; i < 5; i++) {
printf("%d ", array[i]);
}
return 0;
}
Explanation: The 'modifyValues' function adds the square of the index to each element of the array.
void alterArray(int *arr, int size) {
for (int i = 0; i < size; i++) {
arr[i] *= (i + 1);
}
}
int main() {
int array[] = {2, 3, 4, 5, 6};
alterArray(array, 5);
for (int i = 0; i < 5; i++) {
printf("%d ", array[i]);
}
return 0;
}
Explanation: The 'alterArray' function multiplies each element of the array by its index plus 1.
void changeArray(int *arr, int size) {
for (int i = 0; i < size; i++) {
arr[i] -= *(arr + i);
}
}
int main() {
int array[] = {10, 20, 30, 40, 50};
changeArray(array, 5);
for (int i = 0; i < 5; i++) {
printf("%d ", array[i]);
}
return 0;
}
Explanation: The 'changeArray' function subtracts each element of the array from itself.
void updateArray(int *arr, int size) {
for (int i = 0; i < size; i++) {
*(arr + i) *= i;
}
}
int main() {
int array[] = {1, 2, 3, 4, 5};
updateArray(array, 5);
for (int i = 0; i < 5; i++) {
printf("%d ", array[i]);
}
return 0;
}
Explanation: The 'updateArray' function multiplies each element of the array by its index.
void modifyArray(int *arr, int size) {
for (int i = 0; i < size; i++) {
*(arr + i) = *(arr + i) * (*(arr + i));
}
}
int main() {
int array[] = {2, 3, 4, 5, 6};
modifyArray(array, 5);
for (int i = 0; i < 5; i++) {
printf("%d ", array[i]);
}
return 0;
}
Explanation: The 'modifyArray' function squares each element of the array.
void alterValues(int *arr, int size) {
for (int i = 0; i < size; i++) {
*(arr + i) /= (i + 1);
}
}
int main() {
int array[] = {10, 20, 30, 40, 50};
alterValues(array, 5);
for (int i = 0; i < 5; i++) {
printf("%d ", array[i]);
}
return 0;
}
Explanation: The 'alterValues' function divides each element of the array by its index plus 1, which for all indices except 0 results in a division by 0. Thus, the output is 10 10 10 10 10.