How to swap two values using a single variable ?

condition: Not to use Array and Pointer ?

Answer Posted / aditya

main(){
int a=10,b=20;
printf("%d%d",a,b);
a^=b,b^=a,a^=b;
printf("%d%d",a,b);

}

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the two forms of #include directive?

653


What is echo in c programming?

569


Why cant I open a file by its explicit path?

604


Suggesting that there can be 62 seconds in a minute?

608


What is meant by type specifiers?

672






The file stdio.h, what does it contain?

680


The program will first compute the tax you owe based on your income. User is prompted to enter income. Program will compute the total amount of tax owed based on the following: Income Tax 0 - $45,000 = 0.15 x income $45,001 - $90,000 = 6750 + 0.20 x (income – 45000) $90,001 - $140,000 = 15750 + 0.26 x (income – 90000) $140,001 - $200,000 = 28750 + 0.29 x (income – 140000) Greater than $200,000 = 46150 + 0.33 x (income – 200000) Dollar amounts should be in dollars and cents (float point numbers with two decimals shown). Tax is displayed on the screen.

1080


Differentiate Source Codes from Object Codes

840


Explain continue keyword in c

596


If null and 0 are equivalent as null pointer constants, which should I use?

591


When is the “void” keyword used in a function?

855


Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?

2130


Is it possible to execute code even after the program exits the main() function?

834


Write a program to print fibonacci series using recursion?

597


What are c header files?

593