write a program in C to swap two variables

Answer Posted / muzammil

#include <stdio.h>
#include <conio.h>

main()
{
int a,b;
printf("Enter the values: ");
scanf("%d%d",&a,&b);
printf("The values before swapping: %d %d",a,b);
a=a-(b=(-b+(a=a+b)));
printf("The values after swapping are: %d %d",a,b);
getch();
}

Is This Answer Correct ?    14 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When should the register modifier be used? Does it really help?

607


Why do we use static in c?

629


What is structure in c definition?

568


what is a constant pointer in C

674


What are type modifiers in c?

619






What is spark map function?

578


What is pointers in c?

646


What are the standard predefined macros?

627


Explain how can you restore a redirected standard stream?

587


develop algorithms to add polynomials (i) in one variable

1734


What is null character in c?

684


What is the basic structure of c?

551


count = 0; for (i = 1;i < = 10; i++);count = count + i; Value of count after execution of the above statements will be a) 0 b) 11 c) 55 d) array

673


a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion

2330


Is it possible to pass an entire structure to functions?

550