write a prgram of swapping with 2 valiables

Answers were Sorted based on User's Feedback



write a prgram of swapping with 2 valiables..

Answer / eranna kybarshi

#include<stdio.h>
#include<conio.h>
void main()
{
int x,y;
clrscr();

printf("Enter 'x' value :");
scanf("%d",&x);

printf("\nEnter 'y' value :");
scanf("%d",&y);

x=x+y;
y=x-y;
x=x-y;
printf("\nAfter swaping x= %d,y= %d ",x,y);

getch();
}

Is This Answer Correct ?    20 Yes 0 No

write a prgram of swapping with 2 valiables..

Answer / vijay r15

#include<stdio.h>
Void main()
{
int a=10,b=20;
a=a+b-(a=b);
// or use temp var
//or use a^=b^=a
//or use a=a+b;b=a-b;a=a-b;
printf("%d%d",a,b);
}

Any dbt mail to raj.vijay55@gmail.com

Is This Answer Correct ?    3 Yes 1 No

write a prgram of swapping with 2 valiables..

Answer / kumar

#include<stdio.h>
#include<conio.h>
void main()
{
int x,y ;
int z = 0;
clrscr();

printf("Enter 'x' value :");
scanf("%d",&x);

printf("\nEnter 'y' value :");
scanf("%d",&y);

z=x;
x=y;
y=z;
printf("\nAfter swaping x= %d,y= %d ",x,y);

getch();
}

Is This Answer Correct ?    4 Yes 2 No

write a prgram of swapping with 2 valiables..

Answer / aruna.r

#include<stdio.h>
#include<conio.h>
void main()
{
int a=6;
int b=5;
int temp;
temp=a;
a=b;
b=temp;
printf("a & b value %d,%d",a,b);
getch();
}

Is This Answer Correct ?    3 Yes 2 No

write a prgram of swapping with 2 valiables..

Answer / suresh

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
d=0;
printf("enter a");
scanf("%d",&a);
printf("enter b");
scanf("%d",&b);
c=a;
a=b;
b=c;
printf("a & b value are%d%d",a,b);
getch();
}

Is This Answer Correct ?    0 Yes 0 No

write a prgram of swapping with 2 valiables..

Answer / devi

i can swap da 2 variables in singe instr
main()
{
int a,b;
a=(a=(a+b),b=(a-b),a-b);
-------
-------
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

What are the usage of pointer in c?

0 Answers  


What is scope rule in c?

0 Answers  


difference between loading and linking

1 Answers  


How the processor registers can be used in C ?

7 Answers   HP,


write a program that eliminates the value of mathematical constant e by using the formula e=1+1/1!+1/2!+1/3!+

1 Answers   Reliance,






Which are low level languages?

0 Answers  


how to use showbits function?

2 Answers   Infosys, TATA,


You are given a string which contains some special characters. You also have set of special characters. You are given other string (call it as pattern string). Your job is to write a program to replace each special characters in given string by pattern string. You are not allowed to create new resulting string. You need to allocate some new memory to given existing string but constraint is you can only allocate memory one time. Allocate memory exactly what you need not more not less.

2 Answers   Microsoft,


discuss the steps needed to get a program from source code to executable in a system?

1 Answers  


Explain how does flowchart help in writing a program?

0 Answers  


Why do u use # before include in a C Progam?

9 Answers   IBM,


what is the advantage of software development

1 Answers  


Categories