write a program to swap Two numbers without using temp variable.
Answer Posted / tamal datta
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("\n Enter a = ");
scanf("%d",&a);
printf("\n Enter b = ");
scanf ("%d",&b);
printf ("\nBefore swapping a = %d",a);
printf ("\nBefore swapping b = %d",b);
//swaping of 2 numbers without using temp variable
a=a+b;
b=a-b;
a=a-b;
printf("\nAfter swapping a = %d",a);
printf ("\nAfter swapping b= %d",b);
getch();
}
Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
What is omp_num_threads?
What are qualifiers?
What are the advantages of using Unions?
What are the different categories of functions in c?
What is the use of structure padding in c?
What is the difference between a function and a method in c?
How are structure passing and returning implemented?
write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.
What is the scope of local variable in c?
What are the output(s) for the following ? #include char *f() {char *s=malloc(8); strcpy(s,"goodbye")} main() { char *f(); printf("%c",*f()='A'); }
What is the importance of c in your views?
What is the collection of communication lines and routers called?
Hai what is the different types of versions and their differences
What is time null in c?
Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?