josh technology
Company
Programming
#include
void fun(int *p)
{
int q=10;
p=&q;
}
int main(void) {
int r=20;
int *p=&r;
fun(p);
printf("%d",*p);
return 0;
}
Read Solution (Total 6)
-
- it will return the value of r that means 20. bcoz void fun doesn't return any value.
- 8 years agoHelpfull: Yes(1) No(0)
- The answer is 20 because in fun() , the variable p is a local pointer variable of another stack and having another address. So is stores the address of q. But it is not returning anything. So the pointer variable p of main stack is still holding the address of r.
- 8 years agoHelpfull: Yes(1) No(0)
- ans is 20 because there is call by value so there will be no change in the main()
- 8 years agoHelpfull: Yes(0) No(0)
- it is passing value as parameter not reference of r
so ans should be 20 - 8 years agoHelpfull: Yes(0) No(0)
- 20
#include
void fun(int *p)
{
int q=10;
p=&q;
}
int main(void) {
int r=20;
int *p=&r;
fun(p);
printf("%d",*p);
return 0;
} - 7 years agoHelpfull: Yes(0) No(0)
- It firstly point to the r but in main it starts point to the q thus it returns 10 .. Due to call by pointer
- 4 years agoHelpfull: Yes(0) No(0)
josh technology Other Question