6)swap(int x,y)
{
int temp;
temp=x;
x=y;
y=temp;
}
main()
{
int x=2;y=3;
swap(x,y);
}
after calling swap ,what are yhe values x&y?

Answers were Sorted based on User's Feedback



6)swap(int x,y) { int temp; temp=x; x=y; y=temp; } main() { int x=2;y=3; swap(x,y); } af..

Answer / selloorhari

After calling the function swap(), the values of x,y will be
the same.

i.e. x = 2, y = 3.

The scope of the variables x,y,temp in the swap() function
lies inside the function swap() itself. So there will not be
any change in the values of x,y in the main() function..

Is This Answer Correct ?    17 Yes 0 No

6)swap(int x,y) { int temp; temp=x; x=y; y=temp; } main() { int x=2;y=3; swap(x,y); } af..

Answer / shruti

the values will be x =2 and y = 3.

the variables x and y declared in main() are local to main.

whereas

the variables x and y declared in swap() are local to swap..

the change in the value of the variables in either
function will have zero effect on the other function.

Hence the value remains teh same.

Is This Answer Correct ?    16 Yes 1 No

6)swap(int x,y) { int temp; temp=x; x=y; y=temp; } main() { int x=2;y=3; swap(x,y); } af..

Answer / shankar

Value remain same hare....I.E :- X=2,y=3.Because here rules of call by value is applied. If we use call by reference the only value is changed .

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C Interview Questions

a character variable can at a time store a) 1 character b) 8 characters c) 254 characters d) none of the above

3 Answers  


Is void a keyword in c?

0 Answers  


#include<stdio.h> #include<conio.h> void main() { char ch='\356'; printf("%d",ch); } o/p=-18 why?plz.explain

2 Answers  


Difference between goto, long jmp() and setjmp()?

0 Answers   EXL,


a linear linked list such that the link field of its last node points to the first node instead of containing NULL a) linked list b) circular linked list c) sequential linked list d) none

0 Answers  






How to avoid structure padding in C?

8 Answers   Tech Mahindra,


What does %2f mean in c?

0 Answers  


Can you please explain the difference between syntax vs logical error?

0 Answers  


What are 'near' and 'far' pointers?

0 Answers  


Taking an example,differentiate b/w loader and linker ?

1 Answers  


#include<std.h> int main() { char *str[]={"Frogs","Do","Not","Die","They","Croak!"}; printf("%d %d\n",sizeof(str),strlen(str)); ...return 0; } what will the output of the above program?

6 Answers  


please explain every phase in the "SDLC" in the dotnet.

0 Answers  


Categories