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

Answer Posted / sree

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("Enter two numbers");
scanf("%d %d",&a &b);
a=a+b;
b=a-b;
a=a-b;
printf("The swapped values are:");
printf("a:%d",a);
printf("b:%d",b);
getch();
}

Is This Answer Correct ?    73 Yes 24 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is javascript based on c?

599


Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?

585


Why does everyone say not to use scanf? What should I use instead?

685


What is the maximum no. of arguments that can be given in a command line in C.?

674


What are the advantages of using Unions?

647






Create a structure to specify data on students as given below: Roll number, Name, Department, Course, and Year of joining. Assume that there are not more than 450 students in the collage. (a) Write a function to print the names of all students who joined in the last 3 years. (b) Write a function to print the data of a student whose roll numbers are divisible by 4.

609


What are the types of macro formats?

613


What is a lvalue

668


What is union in c?

643


What is the use of function in c?

717


Which programming language is best for getting job 2020?

613


What is sizeof int in c?

608


how logic is used

1504


write a program that types this pattern: 12345678987654321 12345678 87654321 1234567 7654321 123456 654321 12345 54321 1234 4321 123 321 12 21 1 1

3299


Explain what standard functions are available to manipulate strings?

615