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 pointer ? what is the use of pointer?
How many header files are in c?
Why clrscr is used after variable declaration?
Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.
What is the incorrect operator form following list(== , <> , >= , <=) and what is the reason for the answer?
Write a program to reverse a given number in c language?
What kind of sorting is this? SORT (k,n) 1.[Loop on I Index] repeat thru step2 for i=1,2,........n-1 2.[For each pass,get small value] min=i; repeat for j=i+1 to N do { if K[j]<k[min] min=j; } temp=K[i];K[i]=K[min];K[min]=temp; 3.[Sorted Values will be returned] A)Bubble Sort B)Quick Sort C)Selection Sort D)Merge Sort
consagous technology placement paper
write a program to print largest number of each row of a 2D array
write function to reverse char array ... without using second array
I just typed in this program, and it is acting strangely. Can you see anything wrong with it?
int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;