Create a simple code fragment that will swap the values of two variables num1 and num2.



Create a simple code fragment that will swap the values of two variables num1 and num2...

Answer / Nandan Singh

In C, you can use a temporary variable to swap the values of two variables like so:n`n int temp = num1;n num1 = num2;n num2 = temp;n`

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

difference between spiral and waterfall model

1 Answers  


What is table lookup in c?

1 Answers  


Write a program to know whether the input number is an armstrong number.

1 Answers   Wipro,


Write a program that takes a 5 digit number and calculates 2 power that number and prints it.

1 Answers  


What is spark map function?

1 Answers  


What is static memory allocation? Explain

1 Answers  


What is a loop?

1 Answers  


Explain why C language is procedural?

1 Answers   GE,


What does the file stdio.h contain?

1 Answers  


Can you think of a way when a program crashed before reaching main? If yes how?

2 Answers  


What is the difference between far and near ?

1 Answers  


What is the difference between ‘g’ and “g” in C?

2 Answers  


Categories