4 using c language please explain What is the output of foll
?4. using c language, please explain
What is the output of following program #include void foo(int[]); int main() {int ary[4] = {1, 2, 3, 4}; foo(ary); printf(\"%d\", ary[0]);} void foo(int p[4]) {int i = 10; p = &i; printf(\"%d, *p); printf(\"%d \", p[0]);} No answer text proved. 1 1 1 10 10 1 10 1 1Solution
#include <stdio.h>
void foo(int[]);
int main(){
int ary[4] = {1,2,3,4};
foo(ary);
printf(\"%d \",ary[0]); // here at first location, we have 1
return 0;
}
void foo(int p[4]){
int i = 10;
// p is a pointer, here we are storing address of \'i\' in p
p = &i;
printf(\"%d \",*p ); // p has address of i, so output: 10
printf(\"%d \",p[0] ); // p and p[0] denotes first element stored in pointer p
// output: 10
}
Output: 10 10 1
![?4. using c language, please explain What is the output of following program #include void foo(int[]); int main() {int ary[4] = {1, 2, 3, 4}; foo(ary); printf(\ ?4. using c language, please explain What is the output of following program #include void foo(int[]); int main() {int ary[4] = {1, 2, 3, 4}; foo(ary); printf(\](/WebImages/13/4-using-c-language-please-explain-what-is-the-output-of-foll-1017640-1761525978-0.webp)