English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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.

2006-11-01 16:47:20 · 4 answers · asked by Anonymous in Computers & Internet Programming & Design

4 answers

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.

2006-11-01 16:52:00 · answer #1 · answered by Huey L 3 · 2 0

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

2016-10-21 03:15:30 · answer #2 · answered by ? 4 · 0 0

int a =3;
int b =5;
a=^b=^a=^b;

This will swap both the variables a and b;

2006-11-01 18:06:31 · answer #3 · answered by manoj Ransing 3 · 0 2

Ur code is not getting compiled mr. Manoj...

2006-11-01 20:23:03 · answer #4 · answered by Vaibhav 4 · 0 0

fedest.com, questions and answers