Question:
C++ small program ....Challenge?
anonymous
2006-11-01 21:47:20 UTC
plzzzzzz help me with this...............

Write a program that gets 2 integers from the user, swaps their values and displays the
swaped values. You cannot use a third variable/integer.

Forexample: If the user enters values of two integers say a and b as 3 and 5 respectively, then after completion of the program, values of a and b must be 5 and 3 respectively.
Four answers:
Huey L
2006-11-01 21:52:00 UTC
a = a + b;

b = a - b;

a = a - b;



This program should swap perfectly only if sum of a and b will not larger than the max value of their type.
radke
2016-10-21 07:15:30 UTC
set x = your selection set y = your selection divided by capacity of c4ca4238a0b92382dcc509a6f75849b0 set y = int(y) (which will desire to around y all the way down to the subsequent decrease integer) set y = c4ca4238a0b92382dcc509a6f75849b0 * y set z[a million] = y (it is the 1st digit of your new selection) divide x / c4ca4238a0b92382dcc509a6f75849b0 set x = int(x) now repeat the full technique. get it? i'm effective there are prettier approaches nevertheless
manoj Ransing
2006-11-01 23:06:31 UTC
int a =3;

int b =5;

a=^b=^a=^b;



This will swap both the variables a and b;
Vaibhav
2006-11-02 01:23:03 UTC
Ur code is not getting compiled mr. Manoj...


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...