swap prog

Answers were Sorted based on User's Feedback



swap prog..

Answer / venugopal

/* u r question is not clear but i proceed it as a swap of
two numbers*/
main()
{
int a,b,temp;
clrscr();
printf("enter two no's");
scanf("%d %d",&a,&b);
temp=a;
a=b;
b=temp;
printf("after swap no are:");
printf("%d %d" ,a,b);
getch();
} venugopal.palavalasa@gmail.com
}

Is This Answer Correct ?    5 Yes 0 No

swap prog..

Answer / tayyab

By using recent two variables swap code will be
a=3;
b=5;

a=a+b; a=8
b=a-b; b=3
a=a-b; a=5

Is This Answer Correct ?    6 Yes 1 No

swap prog..

Answer / ksrikar

a=9;
b=5;

a=a*b; // a=45
b=a/b; // b=9
a=a/b; // a=5

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More C++ Code Interview Questions

How to swap two ASCII numbers?

0 Answers  


write a c program, using for loop, that accepts and odds two numbers. The output must be the sum and the addens. This should be repeated 5 times while the first number is decremented by one and the second number is incremented by 1.

2 Answers   IBM, Infosys,


Wrie a function which returns the most frequent number in a list of integers. Handle the case of more than one number which meets this criterion. public static int[] GetFrequency(int[] list)

3 Answers   Nagarro,


What output does this program generate as shown? Why? class A { A() { cout << "A::A()" << endl; } ~A() { cout << "A::~A()" << endl; throw "A::exception"; } }; class B { B() { cout << "B::B()" << endl; throw "B::exception"; } ~B() { cout << "B::~B()"; } }; int main(int, char**) { try { cout << "Entering try...catch block" << endl; A objectA; B objectB; cout << "Exiting try...catch block" << endl; } catch (char* ex) { cout << ex << endl; } return 0; }

0 Answers  


Code for Easily Using Hash Table?

0 Answers  






Code for Two Classes for Doing Gzip in Memory?

0 Answers  


write a program that creates a sequenced array of numbers starting with 1 and alternately add 1 and then 2 to create the text number in the series , as shown below. 1,33,4,6,7,9,............147,148,150 Then , using a binary search , searches the array 100 times using randomly generated targets in the range of 1 to 150

0 Answers  


How do I store linked list datas into an array?

1 Answers  


write a program using virtual function to find the transposing of a square matrix?

0 Answers  


Write an algorithm that receives a string and reverses it.

2 Answers  


write a program in c++ to scramble a bmp image file using a scramble key 0x7c and an XOR logic. print out the original image, the scrambled image and the program. Note: the first 24bytes of a bmp file contain the header information of the file.

1 Answers  


Hello, I am trying to write a program in c++ which accepts month and year from the user and prints the calender. So please tell me the algorithm and what is the calender logic.

0 Answers  


Categories