write a program to swap Two numbers without using temp variable.

Answer Posted / amit chauhan

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("\n Enter the 2 numbers");
scanf("%d%d",&a,&b);
//swaping of 2 numbers without using temp variable
a=a+b;
b=a-b;
a=a-b;
/* or
a=a*b;
b=a/b;
a=a/b;
*/
printf("\n A = %d \n B = %d\n");
getch();
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the Purpose of 'extern' keyword in a function declaration?

846


What is wrong with this declaration?

834


What are the different types of C instructions?

966


What are the functions to open and close file in c language?

943


What is the meaning of ?

800


What do you mean by dynamic memory allocation in c?

838


How do you determine the length of a string value that was stored in a variable?

861


Is main a keyword in c?

833


about c language

1795


What are lookup tables in c?

752


Does c have class?

831


Describe explain how arrays can be passed to a user defined function

846


What is the difference between NULL and NUL?

1008


What are the types of unary operators?

880


Create a registration form application by taking the details like username, address, phone number, email with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 3 users and display the details. While taking input password must appear as “****”.

2925