write a program to swap Two numbers without using temp variable.
Answers were Sorted based on User's Feedback
Answer / ramprasad
class Swap
{
static int iValue,jValue,tot;
public static int swap(int A, int B){
tot = A+B;
iValue = tot-B;
jValue = tot-iValue;
return iValue;
//return jValue;
}
public static void main(String[] args)
{
System.out.println(Swap.swap(5,6));
}
}
| Is This Answer Correct ? | 23 Yes | 8 No |
Answer / raghavendra
a=3;
b=2;
a=a^b;
b=a^b;
a=a^b;
printf("%d%d",a,b);
| Is This Answer Correct ? | 34 Yes | 21 No |
Answer / dally
#include<stdio.h>
int main()
{
int a,b;
printf("Enter values for a,b\n");
scanf("%d %d",&a,&b);
b = b+a;
a= b-a;
b=b-a;
printf("a = %d,b = %d",a,b);
}
| Is This Answer Correct ? | 18 Yes | 11 No |
Answer / gouttam pradhan
#include<stdio.h>
main()
{
int a,b;
printf("enter two numbers");
scanf("%d%d",&a&b);
a=a+b;
b=a-b;
a=a-b;
printf("swaped valuess= ",);
printf("a=%d",a);
printf("b=%d",b);
getch();
}
| Is This Answer Correct ? | 6 Yes | 0 No |
Answer / venki
In vb script...............
a=inputbox ("Enter the first value:")
b=inputbox( "Enter the second value:")
msgbox "Before swap a= "&a&" b= "&b
a=cint(a)+cint(b)
b=cint(a)-cint(b)
a=cint(a)-cint(b)
msgbox "After swap a= "&a&" b= "&b
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / 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 |
What is static memory allocation?
How do we print only part of a string in c?
How do you print an address?
Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.
Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.
what is the purpose of the code, and is there any problem with it. unsigned int v[10]; unsigned int i = 0; while (i < 10) v[i] = i++;
int i=3; this declaration tells the C compiler to a) reserve space in memory to hold the integer value b) associate the name i with this memory location c) store the value 3 at this location d) all the above
How do you print only part of a string?
Explain what are the different data types in c?
Explain built-in function?
what is self refrential structure
Sir,please help me out with the output of this programme:- #include<stdio.h> #include<conio.h> void main() { int a=18,b=12,i; for(i=a<b?a:b;a%i||b%i;i--); printf("%d %d",i); }