In order to swap two variable using single expression or in single line we could use bitwise XOR operator of Java. As we now that in Java XOR functions as XOR of two numbers a and b returns a number which has all the bits as 1 wherever bits of a and b differs. So for swapping of two variable we would use this operator as Example Live Demo public class SwapUsingBitwise { public static void main(String[] args) { int a = 8 ; int b = 10; ... Read More
In 8085 Instruction set, INX is a mnemonic that stands for “INcrementeXtended register” and rp stands for register pair. And it can be any one of the following register pairs. rp = BC, DE, or HL This instruction will be used to add 1 to the present content of the rp. And thus the result of the incremented content will remain stored in rp itself. Though it is an arithmetic instruction, note that, flag bits are not at all affected by the execution of this instruction. A register pair is generally used to store 16-bit memory address. If ... Read More
Computer storage has components that store computer data. The different storage types in the storage hierarchy are as follows: Primary Storage This is also known as the main memory and is the memory directly accessible by the CPU. All the instructions are executed in the main memory by CPU and the data required by these instructions is also stored in main memory. Main memory primarily consists of the RAM which is volatile in nature. It is also quite small compared to secondary memory and expensive as well. Secondary Storage Secondary or external storage is not directly accessible by the ... Read More
Python has ability to solve the mathematical expression, statistical data by importing statistic keyword. Python can do various types of statistical and mathematical operations. These functions calculate the average value from a sample or population. mean () Arithmetic mean value (average) of data. harmonic_mean () Harmonic mean value of data. median () Median value (middle value) of data. median__low() Low median value of data. median__high() High median value of data. median__grouped() Median of the grouped data and also calculate the 50th percentile of the grouped data. ... Read More
For swapping characters of a string in Java we can use string builder which is mutable so we need not to take care of new object creation during swapping. In this we would create a method which swap characters of string based on location of swapping characters.This method will take location of swapping characters as its parameters.First store both characters need to be swapped and using set character method of string builder swap the targeted characters. Example Live Demo public class SwapCharacters { public static void main(String[] args) { ... Read More
Definition - In-place operation is an operation that changes directly the content of a given linear algebra, vector, matrices(Tensor) without making a copy. The operators which helps to do the operation is called in-place operator. Eg: a+= b is equivalent to a= operator.iadd(a, b) There are some operators are used for In-place operation. iadd() This function is used to assign the current value and add them. This operator does x+=y operation. In case of strings, numbers assigning is not performed. Example a =operator.iadd(1, 3); print ("The result after adding : ", end="") print(a) Output ... Read More
We can quit/ exit from MySQL stored procedure with the help of the LEAVE command. The following is the syntax. Leave yourLabelName; The following is an example. Here, we are creating a new procedure. mysql> delimiter // mysql> CREATE PROCEDURE ExitQuitDemo2(IN Var1 VARCHAR(20)) -> proc_Exit:BEGIN -> IF Var1 IS NULL THEN -> LEAVE proc_Exit; -> END IF; -> END // Query OK, 0 rows affected (0.16 sec) Above, we have set the following LEAVE command to exit from the procedure. If ... Read More
In 8085 Instruction set, DCX is a mnemonic that stands for “DeCrementeXtended register” and rp stands for register pair. And it can be any one of the following register pairs − rp = BC, DE, or HL This instruction will be used to subtract 1 from the present content of the rp. And thus the result of the decremented content will remain stored in rp itself. Though, it is an arithmetic instruction, note that flags are not at all affected by the execution of this instruction. A register pair is generally used to store 16-bit memory address. If ... Read More
Python has an in built module called calendar which operation is related to calendar. There are some calendar functions in Python. calendar(year, w, l, c) This function shows the year, width of characters, no. of lines per week and column separations. Example print ("The calendar of 2014 is : ") print (calendar.calendar(2014, 3, 1, 4)) Output The calendar of year 2014 is : 2014 January ... Read More
The convert_cyr_string() function is used to convert from one Cyrillic character set to another. The supported Cyrillic character-sets are − k - koi8-r w - windows-1251 i - iso8859-5 a - x-cp866 d - x-cp866 m - x-mac-cyrillic Syntax convert_cyr_string(str, from, to) Parameters str − String to format from − The source Cyrillic character set, as a single character. to − The destination Cyrillic character set, as a single character. Return The convert_cyr_string() function returns the converted string. The following is an example − Example Live Demo ... Read More