0
Not Working
#include<stdio.h> void too (int &y){ printf("y = %d\n",y); y=6; printf("y =%d\n",y); } int main() { int x=5; printf("x = %d\n",x); too(x); printf("x = %d\n",x); return 0; }
7 ответов
+ 1
#include<stdio.h>
void too (int *y) // need a pointer here
{
printf("y = %d\n", *y);
// print value by dereferencing pointer
*y=6;
// change pointer value
printf("y = %d\n", *y);
// print value by dereferencing pointer
}
int main()
{
int x = 5;
printf("x = %d\n", x);
too(&x);
// pass the <x> variable address
printf("x = %d\n", x);
return 0;
}
This works, please see inline comments 👆
+ 1
I think u has to procide y as argument not &y
+ 1
Jordan then u must use return y in toofunction
+ 1
Variable references don't work in C, you must use a pointers.
0
its answer should be
5
5
6
6
0
By writing y
O/p: 5 5 6 5
but correct answer is i mentioned above.