Ask Question
16 March, 19:17

g If you write a C function, named swap, that takes two integers as input arguments and swap them internally. Assume the function returns nothing. Write down the function declaration

+2
Answers (1)
  1. 16 March, 22:36
    0
    void swap (int number1, int number2) {

    printf ("Values before swapping: %d %d / n", number1, number2);

    int temp;

    temp = number1;

    number1 = number2;

    number2 = temp;

    printf ("Values after swapping: %d %d / n", number1, number2);

    }

    Explanation:

    - Print the initial values to see the change

    - Declare a temporary variable temp

    - Assign the value of the number1 to the temp

    - Assign the value of the number2 to number1 (The first number is swapped)

    - Assign the temp value to the number2 (The second number is swapped)

    - Print the new values
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “g If you write a C function, named swap, that takes two integers as input arguments and swap them internally. Assume the function returns ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers