Skip to main content

Posts

Showing posts from December, 2021

Index Sequential Search

 Code for Index Sequential Search  import java . util .*; public class Index_search {     public static void main ( String [] args ) {         int i , a = 0 ;         Scanner in = new Scanner ( System . in );         int arr [] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 };         System . out . println ( "Please enter the number to be find: " );         int num = in . nextInt ();         System . out . println ( "Please enter the steps to left" );         int steps = in . nextInt ();         in . close ();         for ( i = 0 ; i < arr . length ; ) {             if ( num == arr [ i ] ) {                 System . out . println ( "Number found in the first one. " + i );       ...

Pattern : Pattern 13

Pattern 13   import java . util . Scanner ; public class Pattern13 {     public static void main ( String [] args ) {         Scanner in = new Scanner ( System . in );         System . out . println ( "Enter the no. of rows to be printed: " );         int n = in . nextInt ();             for ( int i = 0 ; i < n ; i ++) {             for ( int sp = 0 ; sp < n - i ; sp ++)             {                 System . out . print ( " " );             }             for ( int j = 0 ; j < n ; j ++)             {               System . out . print ( "#" );               }           ...

Pattern : Pattern 12

Pattern 12   import java . util . Scanner ; public class Pattern12 {     public static void main ( String [] args ) {         Scanner in = new Scanner ( System . in );         System . out . println ( "Enter the no. of rows to be printed: " );         int n = in . nextInt ();         for ( int i = 0 ; i < n ; i ++) {             for ( int j = 0 ; j < n + i ; j ++) {                 if ( j <= i ) {                     System . out . print ( " " );                 }                 else  {                     System . out . print ( "#" );                 }      ...

Pattern : Pattern 11

  import java . util .*; public class Pattern11 {     public static void main ( String [] args ) {         Scanner in = new Scanner ( System . in );         System . out . println ( "Enter the no. of rows to be printed: " );         int n = in . nextInt ();         for ( int i = 0 ; i < n ; i ++) {             for ( int j = 0 ; j < n ; j ++) {                 if ( i - j == 0 ) {                     System . out . print ( "#" );                 }                 else if ( i + j ==( n - 1 )) {                     System . out . print ( "#" );                 }       ...

Pattern : Pattern 10

  import java . util . Scanner ; public class Pattern10 {     public static void main ( String [] args ) {         Scanner in = new Scanner ( System . in );         System . out . println ( "Enter the no. of rows to be printed: " );         int n = in . nextInt ();         for ( int i = 0 ; i < n ; i ++) {             for ( int j = 0 ; j < n ; j ++) {                 if ( i - j <= 0 ) {                     System . out . print ( "# " );                 }                 else                 {                     System . out . print ( " " );           ...

Pattern : Pattern 9

  import java . util . Scanner ; public class Pattern9 {     public static void main ( String [] args ) {         Scanner in = new Scanner ( System . in );         System . out . println ( "Enter the no. of rows to be printed: " );         int n = in . nextInt ();         for ( int i = 0 ; i < n ; i ++) {             for ( int j = 0 ; j < n ; j ++) {                 if ( i - j <= 0 ) {                     System . out . print ( "#" );                 }                 else                 {                     System . out . print ( " " );            ...

Pattern : Pattern 8

  import java . util .*; public class Pattern8 {     public static void main ( String [] args ) {         Scanner in = new Scanner ( System . in );         System . out . println ( "Enter the no. of rows you want" );         int n = in . nextInt ();         for ( int i = 0 ; i < n ; i ++) {             for ( int j = 0 ; j < n ; j ++) {                 if ( i + j <=( n - 1 )) {                     System . out . print ( "# " );                 }             }             System . out . println ( "" );         }         for ( int i = 1 ; i < n ; i ++) {       // Here i = 1 is taken so that...

Pattern : Pattern 7

  import java . util .*; public class Pattern7 {     public static void main ( String [] args ) {         Scanner in = new Scanner ( System . in );         System . out . println ( "Enter the no. of rows you want" );         int n = in . nextInt ();         for ( int i = 0 ; i < n ; i ++) {             for ( int j = 0 ; j < n ; j ++) {                 if ( i + j >=( n - 1 )) {                     System . out . print ( "# " );                 }                 else                 {                     System . out . print ( " " );              ...

Pattern : Pattern 6

  import java . util .*; public class Pattern6 {     public static void main ( String [] args ) {         Scanner in = new Scanner ( System . in );         System . out . println ( "Enter the no. of rows you want" );         int n = in . nextInt ();         for ( int i = 0 ; i < n ; i ++) {             for ( int j = 0 ; j < n ; j ++) {                 if ( i + j >=( n - 1 )) {                     System . out . print ( "#" );                 }                 else                 {                     System . out . print ( " " );               ...

Pattern : Pattern 5

  import java . util .*; public class Pattern5 {     public static void main ( String [] args ) {         Scanner ab = new Scanner ( System . in );         System . out . println ( "Enter the no. of rows you want in the Pattern:" );         int a = ab . nextInt ();         for ( int i = 0 ; i < a ; i ++)        {             for ( int j = 0 ; j < a ; j ++)            {                 if ( i + j >=( a - 1 )) {                     System . out . print ( "*" );                 }                 else                 {                     ...

Pattern : Pattern 4

  import java . util .*; public class Pattern4 {     public static void main ( String [] args ) {         Scanner in = new Scanner ( System . in );         System . out . println ( "Please enter no. of rows to be printed:" );         int n = in . nextInt ();         for ( int i = 0 ; i < n ; i ++) {             for ( int j = 0 ; j < n ; j ++) {                 if ( i + j <=( n - 1 )) {                     System . out . print ( "#" );                 }             }             System . out . println ( "" );         }         in . close ();     } }

Pattern : Pattern 3

  import java . util .*; public class Pattern3 {     public static void main ( String [] args ) {         Scanner ab = new Scanner ( System . in );         System . out . println ( "Enter the no. of rows you want in the Pattern:" );         int a = ab . nextInt ();         for ( int i = 1 ; i <= a ; i ++)        {             for ( int j = 1 ; j <= a ; j ++)            {                 if ( i - j <= 0 )                 {                     System . out . print ( "# " );                 }                 else                 {     ...

Pattern : Pattern 2

import java . util .*; public class Pattern2 {     public static void main ( String [] args ) {         Scanner ab = new Scanner ( System . in );         System . out . println ( "Enter the no. of rows you want in the Pattern:" );         int a = ab . nextInt ();         for ( int i = 1 ; i <= a ; i ++)        {             for ( int j = 1 ; j <= a ; j ++)            {                 if ( i - j <= 0 )                 {                     System . out . print ( "# " );                 }                 else                 {       ...

Pattern: Pattern 1

import java . util .*; public class Pattern1 {     public static void main ( String [] args ) {         Scanner ab = new Scanner ( System . in );         System . out . println ( "Enter the no. of rows you want in the Pattern:" );         int a = ab . nextInt ();         for ( int i = 1 ; i <= a ; i ++)        {             for ( int j = 1 ; j <= a ; j ++)            {                 if ( i - j >= 0 ) {                     System . out . print ( "# " );                 }            }             System . out . println ( "" );        }         ab . close ();   ...