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



Explain this code. #include <stdio.h> void f1(int *k) { *k = *k + 10; } main (..

Answer / pooja agarwal

10

Is This Answer Correct ?    11 Yes 0 No

Explain this code. #include <stdio.h> void f1(int *k) { *k = *k + 10; } main (..

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

Explain this code. #include <stdio.h> void f1(int *k) { *k = *k + 10; } main (..

Answer / vivek

it will produce an error as constant cant be added to a pointer

Is This Answer Correct ?    1 Yes 4 No

Post New Answer

More C Interview Questions

Write a program to identify if a given binary tree is balanced or not.

0 Answers   JPMorgan Chase,


Three major criteria of scheduling.

1 Answers  


Two's compliment of -5

4 Answers   Adobe,


You have an int array with n elements and a structure with three int members. ie struct No { unsigned int no1; unsigned int no2; unsigned int no3; }; Point1.Lets say 1 byte in the array element is represented like this - 1st 3 bits from LSB is one number, next 2 bits are 2nd no and last 3 bits are 3rd no. Now write a function, struct No* ExtractNos(unsigned int *, int count) which extracts each byte from array and converts LSByte in the order mentioned in point1.and save it the structure no1, no2, no3. in the function struct No* ExtractNos(unsigned int *, int count), first parameter points to the base address of array and second parameter says the no of elements in the array. For example: if your array LSB is Hex F7 then result no1 = 7, no2 = 2, no3 = 7. In the same way convert all the elements from the array and save the result in array of structure.

2 Answers   Qualcomm,


What is the difference between constant pointer and constant variable?

0 Answers   NIIT,






What is the argument of a function in c?

0 Answers  


What is structure data type in c?

0 Answers  


#define swap1(a,b) a=a+b;b=a-b;a=a-b; main() { int x=5,y=10; swap1(x,y); printf("%d %d\n",x,y); swap2(x,y); printf("%d %d\n",x,y); } int swap2(int a,int b) { int temp; temp=a; b=a; a=temp; return; } what are the outputs?

4 Answers   Ramco,


How do you redirect a standard stream?

0 Answers  


What is #include stdio h?

0 Answers  


if p is a string contained in a string?

0 Answers  


What is identifiers in c with examples?

0 Answers  


Categories