Answer to Question #202538 in C for Nanba

Question #202538

Write a program to swap two numbers using temporary variables and functions (call by value).


Runtime Input :


12

5


Output :


5

12


1
Expert's answer
2021-06-03T13:42:26-0400
#include <stdio.h>
  
int main()
{
    int x, y;
    printf("Enter Value of x ");
    scanf("%d", &x);
    printf("\nEnter Value of y ");
    scanf("%d", &y);
  
    int temp = x;
    x = y;
    y = temp;
  
    printf("\nAfter Swapping: x = %d, y = %d", x, y);
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS