write a program in C to swap two variables

Answer Posted / priyamurugan

#include<stdio.h>
#include<conio.h>
main()
{
int a,b;
printf("\n BEFORE SWAPPING THE NOS");
printf("\n enter the a, b values");
scanf("%d %d",&a,&b);
swap(&a,&b);
printf("\n AFTER SWAPPING THE NOS");
printf("\n a=%d",a);
printf("\n b=%d",b);
getch();
}
swap(int *x,int *y)
{
int t;
t=*x;
*x=*y;
*y=t;
return();
}

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain 'bus error'?

573


What are the benefits of c language?

657


Write the Program to reverse a string using pointers.

629


What are register variables? What are the advantage of using register variables?

698


Given below are three different ways to print the character for ASCII code 88. Which is the correct way1) char c = 88; cout << c << " ";2) cout.put(88);3) cout << char(88) << " "; a) 1 b) 2 c) 3 d) constant

678






Explain the properties of union.

617


What is the use of getchar functions?

690


What is the use of ?: Operator?

673


How can I trap or ignore keyboard interrupts like control-c?

629


What is d scanf?

609


What is s in c?

626


What are the advantages of using new operator as compared to the function malloc ()?

764


What is the time and space complexities of merge sort and when is it preferred over quick sort?

682


What is the auto keyword good for?

636


What is call by value in c?

575