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

On most computers additional memory that is accessed through an adapter of feature card along with a device driver program. a) user memory b) conventional memory c) expandedmemory d) area

0 Answers  


What are the preprocessor categories?

0 Answers  


What should be keep precautions while using the recursion method?

1 Answers  


Explain how can I convert a string to a number?

0 Answers  


Explain what’s a signal? Explain what do I use signals for?

0 Answers  






write a 'c' program to sum the number of integer values

8 Answers  


What is dynamic variable in c?

0 Answers  


What is the difference between Printf(..) and sprint(...) ?

0 Answers   InterGraph,


Write a C program to multiply tho numbers without using arithmetic operator (+, -, *, /).

1 Answers  


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?

3 Answers  


Define macros.

0 Answers   Tech Mahindra,


what is default constructor?

2 Answers   HCL,


Categories