write a program in C to swap two variables

Answer Posted / srinivas

#include <stdio.h>

int main(void)
{
int a = 2, b = 5;

a = a + b;
b = a - b;
a = a - b;
printf("%d\t%d\n", a, b);
return 0;
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is extern used in c?

623


Is c procedural or functional?

595


What is #define?

584


Dont ansi function prototypes render lint obsolete?

616


Is there a way to jump out of a function or functions?

648






I need a sort of an approximate strcmp routine?

667


Differentiate abs() function from fabs() function.

615


How are portions of a program disabled in demo versions?

765


Why we write conio h in c?

577


Was 2000 a leap year?

642


How can I run c program?

699


Where is volatile variable stored?

657


What is equivalent to ++i+++j?

653


Write a program to print factorial of given number using recursion?

609


How many types of functions are there in c?

591