Skip to main content

Posts

Showing posts from March, 2018

Is the Number is Rotated?

Java code to check weather the second number is rotated version of the first number without converting it to string or array....frequently asked in interviews..... Follow me @ facebook     @linkedIn //*********************************Coded-By : SOMES KUMAR K.*******************************//   //*********************************LEARN CODE WITH FUN*************************************// import java.util.Scanner; public class Find_Number_Rotated { int find_count( int a){ int c= 0 ; while (a> 0 ){ c++; a=a/ 10 ; } return c; } public static void main(String[] args) { Find_Number_Rotated no = new Find_Number_Rotated(); boolean xc= false ; Scanner s1 = new Scanner(System. in ); int a= s1.nextInt(); int data = s1.nextInt(); int c = no.find_count(a); int th= 1 ; for ( int i= 0 ;i<c;i++) th*= 10 ; int b=(a*th)+a; int s

X-O game using JAVA

Here, you can find a basic java code to implement X-O game. Follow me @ facebook //*********************************Coded-By : SOMES KUMAR K.*******************************//   //*********************************LEARN CODE WITH FUN*************************************//     import java.util.Scanner; public class X_O_Game { int xi , xj ; static Scanner s = new Scanner(System. in ); char board [][]; public void make_board( int n){ if (n% 2 != 0 ){ setBoard(n); } else { System. out .println( "Enter valid Board Size" ); n = s .nextInt(); make_board(n); } } public void setBoard( int size) { board = new char [size][size]; for ( int i= 0 ;i<size;i++){ for ( int j= 0 ;j<size;j++){ board [i][j]= ' ' ; } } } boolean check_board_empty( int size){ boolean c= true ;

Arrays using Pointers..

In this blog let’s try to understand about pointer.   So, what is pointer?... pointer is thing that used to point something in a group. For example, Here, the pointer is used to point the temperature in the gauge. Similarly, in computer the data gets stored in memory and each data is assigned with an address in the memory. So, the pointer is used to point the data, in other words pointer contains a memory address of that particular data. (int a = 10; here the ‘a’ indirectly act as a pointer which has the value ‘10’.) Now we can see that how arrays are similar with pointer. We know that array is a continuous block of memory that stores multiple data of same kind. Let’s have a close look In c program pointer a declared with ’*’   symbol followed by a variable (eg : int *ptr). int a[10];---------------------------( 1 )------------------> this array stores 10 integers at max, here all elements in array is referenced with the variable ‘a’. which is more less equ