Java
Swap Two Numbers With and Without Third Variable In Java
[crayon-5a2bbab1b38f7332524218/] [crayon-5a2bbab1b3903540302338/]
Pursuing MCA from YMCA University, Faridabad
[crayon-5a2bbab1b38f7332524218/] [crayon-5a2bbab1b3903540302338/]
We can reverse the number and check if they are equal. [crayon-5a2bbab1b3f8b114581642/] Output [crayon-5a2bbab1b3f97394072835/] Discussion Above program is just show of logic and for generic program you need to change few things. Compiled with JDK 9
[crayon-5a2bbab1b421f751840772/] Output 5984984 Discussion For ‘for’ loop use – for(;num!=0;) Compiled with JDK 9
[crayon-5a2bbab1b43f0353556505/] Output [crayon-5a2bbab1b43f7919447789/] Discussion — Your output will be Different. For More details Visit : https://docs.oracle.com/javase/9/docs/api/java/util/Random.html
[crayon-5a2bbab1b45a8065282975/] 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 result Also you need to import java.text.DecimalFormat. Compiled with JDK Read more…
[crayon-5a2bbab1b476b121604665/] output [crayon-5a2bbab1b4772950038569/] Compiled with JDK 9
[crayon-5a2bbab1b4926328241652/] Output [crayon-5a2bbab1b492e511114551/] 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 use getClass() with primitive type because those are not classes Read more…
[crayon-5a2bbab1b4b41927920158/] Discussion This example has been compiled with JDK 9 Output [crayon-5a2bbab1b4b49483817485/] 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 on all the data types and see what will be Read more…
Merge Sort Program Implementation in C [crayon-5a2bbab1b4f44549951202/]