write a program to swap Two numbers without using temp variable.
Answers were Sorted based on User's Feedback
Answer / riyaz
int a, b;
printf("a=");
scanf("%d",&a);
printf("b=");
scanf("%d",&b);
printf("a = %d\nb = %d\n",b,a);
return 0;
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / ragini
#include<stdio.h>
#include<conio.h>
void swap(int a,int b);
void main()
{
int a,b;
swap(a,b);
printf("Enter the 2 nos");
scanf("%d%d",&a,&b);
}
void swap(int x,int y)
{
x=x*y;
y=x/y;
x=x/y;
}
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ankur
Check the answer here
http://www.lifengadget.com/lifengadget/program-interchange-two-numbers-without-using-third-variable/
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / romeld
#include<stdio.h>
main()
{
int a,b;
printf("enter the value of a and b\n");
scanf("%d%d",&a,&b);
printf("before swapping\na=%d\nb=%d\n",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("after swapping\na=%d\nb=%d\n",a,b);
getch();
}
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / diponkor roy
#include<iostream>
using namespace std;
int main()
{
int x,y;
cin>>x;
cin>>y;
cout<<"You enter"<<x <<" and"<<y<<endl;
x=x*y;
y=x/y;
x=x/y;
cout<<"After swap your number "<<x <<" and"<<y<<endl;
return 0;
}
Is This Answer Correct ? | 2 Yes | 3 No |
Answer / ratna
#include<stdio.h>
main()
{
int x,y;
printf("\n enter the two numbers:\n");
scanf("%d%d",&x,&y);
y=(x+y)-y;
x=(x+y)-x;
printf("\n x=%d \n y=%d\n");
getch();
}
output: enter the two numbers:10
20
execute the conditions y=30-20=10
x=30-10=20
finally display the output:20 10
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / manas ranjan(gift)
#include<stdio.h>
void main()
{
int a,b;
printf("enter the numbers");
scanf("%d%d",&a,&b);
printf("before swaping the values are");
printf("a=%d,b=%d",a,b);
void swap(int,int);
swap(a,b);
}
void swap(int a,int b)
{
a=a+b;
b=a-b;
a=a-b;
printf("a=%d,b=%d",a,b);
}
Is This Answer Correct ? | 0 Yes | 2 No |
Answer / prudhvi
int a, b, c;
a = int.Parse(Console.ReadLine());
b = int.Parse(Console.ReadLine());
c = b;
b = a;
a = c;
Console.WriteLine("a={0},b={1}",a,b);
Console.ReadLine();
}
Is This Answer Correct ? | 0 Yes | 2 No |
mplementation of stack using any programing language
Difference between linking and loading?
What's the difference between struct x1 { ... }; and typedef struct { ... } x2; ?
please give me answer with details #include<stdio.h> main() { int i=1; i=(++i)*(++i)*(++i); printf("%d",i); getch(); }
any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above
what is the Output? int a=4 b=3; printf("%d%d%d%d%d%d",a++,++a,a++,a++,++a,a++); printf("%d%d%d%d%d%d",b--,b--,--b,b--,--b,--b);
write a C program: To recognize date of any format even formats like "feb-02-2003","02-february-2003",mm/dd/yy, dd/mm/yy and display it as mm/dd/yy.
Why is extern used in c?
Differentiate between null and void pointers.
can anyone please tell about the nested interrupts?
what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?
What is break statement?