Explain this code.
#include <stdio.h>
void f1(int *k)
{
*k = *k + 10;
}
main ( ){
int i;
i = 0;
printf (" The value of i before call %d \n", i);
f1 (&i);
printf (" The value of i after call %d \n", i);
}
Answers were Sorted based on User's Feedback
Answer / ankita sharma
answer will be 10. as k has the address of i so when we write *k=*k+10; *k meand that value to which k is pointing so it is pointing to i and i has the value 0 as intial value so 10 would be added to the value of i. so output will be 10.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / vivek
it will produce an error as constant cant be added to a pointer
| Is This Answer Correct ? | 1 Yes | 4 No |
What is abstract data structure in c?
Discuss similarities and differences of Multiprogramming OS and multiprocessing OS?
What is the difference between Printf(..) and sprint(...) ?
What is the scope of global variable in c?
swap two integer variables without using a third temporary variable?
List the difference between a While & Do While loops?
Why we use stdio h in c?
What is the use of ?: Operator?
Where does the name "C" come from, anyway?
What is strcmp in c?
How are pointers declared in c?
who developed c and why he developed c?