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

What are linked lists in c?

651


What is a node in c?

551


Explain what is page thrashing?

612


Write a code of a general series where the next element is the sum of last k terms.

597


write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays

1787






What is the difference between array_name and &array_name?

780


What is the purpose of type declarations?

682


What are identifiers and keywords in c?

574


How can I manipulate strings of multibyte characters?

640


What is preprocessor with example?

590


pgm to find any error in linklist(in single linklist check whether any node points any of previous nodes instead of next node)

2202


What are qualifiers and modifiers c?

550


What is scope rule in c?

608


What is size of union in c?

582


What is the size of structure in c?

703