#include<stdio.h>int main() { int x,y; scanf("%d %d",&x,&y); printf("maximum number is :%i",(abs(x-y)+(x+y))/2);//%i or %d can be used printf("minimum number is :%i",(abs(x-y)-(x+y))/2);}#include<stdio.h>#include<string.h>int main() { char array[64];float myInteger = 4711;sprintf( array, "%.1f", myInteger );printf( "%s", array );}METHOD 1:
The bitwise XOR operator can be used to swap two variables.
The XOR of two numbers x and y returns a number which has all the bits as 1 wherever bits of x and y differ.
For example XOR of 10 (In Binary 1010) and 5 (In Binary 0101) is 1111 and XOR of 7 (0111) and 5 (0101) is (0010).
x = x ^ y; // x now becomes 15 (1111) y = x ^ y; // y becomes 10 (1010) x = x ^ y; // x becomes 5 (0101) Note:It is the best approach compared to other 2 methods.
The idea is to get sum in one of the two given numbers. The numbers can then be swapped using the sum and subtraction from sum.
x = x + y; y = x - y; x = x - y; Note:Arithmetic solutions may cause arithmetic overflow. If x and y are too large, addition and multiplication may go out of integer range.
Multiplication and division can also be used for swapping.
x = x * y; y = x / y; x = x / y; Note:The multiplication and division based approach doesn’t work if one of the numbers is 0 as the product becomes 0 irrespective of the other number.
x=x^y^z; y=x^y^z; z=x^y^z; x=x^y^z;Note:
x1=x1^x2^x3^....^xn; x2=x1^x2^x3^....^xn; x3=x1^x2^x3^....^xn; . . xn=x1^x2^x3^....^xn; x1=x1^x2^x3^....^xn;