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

Answer Posted / sneha

two ways to swap a number....
1st method
main()
{
int a,b;
printf("enter two numbers for swaping");
scanf("%d%d",&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf("a=%d,b=%d",a,b)
getch()
}

2nd method
main()
{
int a,b;
printf("enter two numbers for swaping");
scanf("%d%d",&a,&b);
a=a*b;
b=a/b;
a=a/b;
printf("a=%d,b=%d",a,b)
getch()
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Where are c variables stored in memory?

590


write an algorithm to display a square matrix.

2213


Differentiate between calloc and malloc.

747


What is abstract data structure in c?

517


Tell me when would you use a pointer to a function?

596






#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }

620


what are the advantages of a macro over a function?

633


Which is an example of a structural homology?

769


#include { printf("Hello"); } how compile time affects when we add additional header file .

1416


1) write a program to generate 1st n fibonacci prime numbers using Nested if 2) write a program to generate twin prime numbers from m to n using nested if 3) write a program to check whether a given integer is a strong number or not using nested if 4) Write a program to generate prime factors of a given integer using nested if 5)write a program to generate prime numbers from m to n using nested if 6)write a program to generate perfect numbers from m to n using nested if 7)write a program to generate the pallindromes from m to n using neste if 8)write a program to generate armstrong numbers from m to n using nested if 9)write a program to generate strong numbers from m to n using nested if

3973


What is null pointer in c?

585


What are structural members?

562


count = 0; for (i = 1;i < = 10; i++);count = count + i; Value of count after execution of the above statements will be a) 0 b) 11 c) 55 d) array

669


When was c language developed?

689


What are lookup tables in c?

540