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

Answer Posted / sams

Two numbers are input through the keyboard into two
locations C and D. Write a program to interchange the
contents of C and D.



#include<stdio.h>

#include<conio.h>
void main( )
{
int a,b,c;
clrscr( );
printf("Enter A: ");
scanf("%d",&a);

printf("Enter B: ");
scanf("%d",&b);

c=a;
a=b;
b=c;

printf("\n The New Value Of A is : %d",a);
printf("\n The New Value Of B is : %d",b);


getch();
}

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the scope of global variable in c?

533


Tell me what is null pointer in c?

589


How do you redirect a standard stream?

598


What is break statement?

606


a value that does not change during program execution a) variabe b) argument c) parameter d) none

668






Can we initialize extern variable in c?

603


Explain how can type-insensitive macros be created?

547


What are the types of variables in c?

559


What is nested structure with example?

600


When should structures be passed by values or by references?

545


What is the use of define in c?

565


Can we use any name in place of argv and argc as command line arguments?

586


What is a structure in c language. how to initialise a structure in c?

581


What is difference between union and structure in c?

549


The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?

736