What is the output of the following C code:#include <stdio.h>void fun(int **p);int main(){ int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 8, 7, 8, 9, 0}; int *ptr; ptr = &a[0][0]; fun(&ptr); return 0;}void fun(int **p){ printf("%d\n", **p);}1234
Question
What is the output of the following C code:#include <stdio.h>void fun(int **p);int main(){ int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 8, 7, 8, 9, 0}; int *ptr; ptr = &a[0][0]; fun(&ptr); return 0;}void fun(int **p){ printf("%d\n", **p);}1234
Solution
The given code is written in C programming language. It declares a function fun that takes a double pointer p as a parameter. The main function initializes a 2D array a with some values and assigns the address of the first element of a to a pointer ptr. Then, it calls the fun function by passing the address of ptr as an argument. Finally, the fun function prints the value at the address pointed by p using double dereference operator **p.
The expected output of the given code is 1, as it will print the value at the address ptr, which is the first element of the 2D array a.
Similar Questions
What is the output of the C Program?
What is the output for the following code?
What will be the output of the following C++ code?
What will be the output of the following C code?#include <stdio.h>int main() { int i; for (i = 0; i < 5; i++); printf("%d\n", i); return 0;}
What would be the output of the following program? #include <stdio.h> int main( ) { int j=1; while (j <= 255) { printf ( "%c %d\n ", j, j ); j++; } return 0; }
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.