Java
Swap Two Numbers With and Without Third Variable In Java
[crayon-5a2bba714ccac229447242/] [crayon-5a2bba714ccba125977228/]
[crayon-5a2bba714ccac229447242/] [crayon-5a2bba714ccba125977228/]
We can reverse the number and check if they are equal. [crayon-5a2bba714d3b0053907189/] Output [crayon-5a2bba714d3bb917674866/] Discussion Above program is just show of logic and for generic program you need to change few things. Compiled with JDK 9
[crayon-5a2bba714d648910300810/] Output 5984984 Discussion For ‘for’ loop use – for(;num!=0;) Compiled with JDK 9
[crayon-5a2bba714d879228371573/] Output [crayon-5a2bba714d883787748319/] Discussion — Your output will be Different. For More details Visit : https://docs.oracle.com/javase/9/docs/api/java/util/Random.html
[crayon-5a2bba714dae4557121185/] Output Average is : 4.857142857142857 Discussion To limit the digits after decimal use : ‘DecimalFormat’ Class or System.out.format() or String.format or System.out.printf() e.g. DecimalFormat newDecimalFormat = new DecimalFormat(“#:00”); newnumber = newDecimalFormat.format(whateverYourNumberIs); It will give you 4.85 according for above Read more…
[crayon-5a2bba714dce9719317009/] output [crayon-5a2bba714dcf1845470020/] Compiled with JDK 9
[crayon-5a2bba714df30875958549/] Output [crayon-5a2bba714df3b185861990/] Discussion Now from above we can say that array is a class and we have created various objects of it and we can also find which type of data it contains. But be carefull that you don’t Read more…
[crayon-5a2bba714e1ca928245371/] Discussion This example has been compiled with JDK 9 Output [crayon-5a2bba714e1d3566792252/] We can see that type (class) of array can be retrived from getClass() and Name of Class with getName(). In next post we will use getClass and getName Read more…
Merge Sort Program Implementation in C [crayon-5a2bba714e65f208958272/]