Knowee
Questions
Features
Study Tools

n the following code,int f(int *a) {  *a  = 20;}int main() { int m = 30; f(&m);}a.The parameter passing is "pass by address", and the "address of m" is passedb.Parameter passing is by value, the value passed is "address of m", and copied into the argument *a c.Parameter passing is by value, the value passed is "m", and copied into the argument a d.Parameter passing is by value, the value passed is "address of m", and copied into the argument ae.The parameter passing is "pass by reference" and variable a is a reference to variable m.

Question

n the following code,int f(int *a) {  *a  = 20;}int main() { int m = 30; f(&m);}a.The parameter passing is "pass by address", and the "address of m" is passedb.Parameter passing is by value, the value passed is "address of m", and copied into the argument *a c.Parameter passing is by value, the value passed is "m", and copied into the argument a d.Parameter passing is by value, the value passed is "address of m", and copied into the argument ae.The parameter passing is "pass by reference" and variable a is a reference to variable m.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

The correct answer is b. Parameter passing is by value, the value passed is "address of m", and copied into the argument *a. This is because in C, all function arguments are passed by value. The value here is the address of m, which is why we use the & operator. This address is then copied into the pointer a in the function f. The function then modifies the value at that address to be 20, which is why the value of m in the main function is changed after the function call.

This problem has been solved

Similar Questions

n the following code,int f(int *a) {  *a  = 20;}int main() { int m = 30; f(&m);}a.The parameter passing is "pass by address", and the "address of m" is passedb.Parameter passing is by value, the value passed is "address of m", and copied into the argument *a c.Parameter passing is by value, the value passed is "m", and copied into the argument a d.Parameter passing is by value, the value passed is "address of m", and copied into the argument ae.The parameter passing is "pass by reference" and variable a is a reference to variable m.

What will be the output of the following code?int main() {    int a = 10;    int *p = &a;    *p = 20;    printf("%d\n", a);    return 0;}

What is the output of below C program? #include <stdio.h> int main() { int k = 5; int *p = &k; int **m = &p; **m = 6; printf("%d\n", k); } 5 6 garbage Compile time error

find the output of given code.#include <stdio.h>int main(){int a,b=110,c=20;printf("%d",a=b-=c*=5);return 0;}

What will be the output of the following code?   int main() {int x = 5;int * ptr = &x;*ptr + 1;cout << (*ptr)++;}

1/3

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.