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?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I read a binary data file properly?

637


What is the role of && operator in a program code?

572


using only #include and #include Write a program in C that will read an input from the user and print it back to the user if it is a palindrome. The string ends when it encounters a whitespace. The input string is at most 30 characters. Assume the string has no spaces and distinguish between and lowercase. So madam is a palindrome, but MadAm is not a palindrome. Use scanf and %s to read the string. Sample Test: Enter a string: madam madam is a palindrome. Enter a string: 09023 09023 is not a palindrome.

1316


I need a sort of an approximate strcmp routine?

663


Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)

817






Why do we use pointer to pointer in c?

602


Can i use “int” data type to store the value 32768? Why?

758


Difference between Function to pointer and pointer to function

636


What are inbuilt functions in c?

562


What is the use of extern in c?

651


Differentiate fundamental data types and derived data types in C.

621


What is the deal on sprintf_s return value?

647


Explain what is a pragma?

596


What are the advantages of using Unions?

643


What is c language used for?

562