EmSAT Achieve Exam  >  EmSAT Achieve Notes  >  Java for EmSAT Achieve  >  Code: Number Patterns

Code: Number Patterns | Java for EmSAT Achieve PDF Download

Code: Number Patterns | Java for EmSAT Achieve

1. Write a python program to print following number pattern: 

Code: Number Patterns | Java for EmSAT Achieve

public class CharacterPattern

{

   public static void main(String[] args) 

   {

      int n=5;

      for(int i=1, p=1; i<=n; i++, p++){

        for(int j=1; j<=i; j++){

           System.out.print(p+" ");

        }

        System.out.println();

    }

  }

}

2. Write a python program to print following pattern: 

Code: Number Patterns | Java for EmSAT Achieve

public class CharacterPattern

{

   public static void main(String[] args) 

   {

      int n=5;

      for(int i=1, p=5; i<=n; i++, p++){

        for(int j=1; j<=i; j++){

           System.out.print(p+" ");

        }

        System.out.println();

     }

  }

}

3. Write a python code to print following number pattern: 

Code: Number Patterns | Java for EmSAT Achieve

public class CharacterPattern

{

   public static void main(String[] args) 

   {

      int n=5;

      for(int i=1, p=5; i<=n; i++, p+=2){

         for(int j=1; j<=i; j++){

            System.out.print(p+" ");

         }

         System.out.println();

     }

  }

}

4. Write a python code to print following pattern: 

Code: Number Patterns | Java for EmSAT Achieve

public class CharacterPattern 

{

   public static void main(String[] args)

   { 

      int n=5;

      for(int i=1; i<=n; i++){

         for(int j=1; j<=i; j++){

            if(i%2==0)

               System.out.print("2 ");

            else

               System.out.print("1 ");

         }

         System.out.println();

     }

   }

}

5. Write a python program to print following Dimond number pattern: 

Code: Number Patterns | Java for EmSAT Achieve

public class CharacterPattern

{

   public static void main(String[] args)

   {

      int n= 5,p=1;

      for(int i=1; i<n; i++, p++){

        for(int j=i; j<=n; j++){

           System.out.print(" ");

        }

        for(int j=1; j<i; j++){

           System.out.print(p +" ");

        }

        for(int j=1; j<=i; j++){

           System.out.print(p +" ");

        }

        System.out.println();

     }

     for(int i=1; i<=n; i++, p++){

        for(int j=1; j<=i; j++){

           System.out.print(" ");

        }

        for(int j=i; j<n; j++){

           System.out.print(p +" ");

        }

        for(int j=i; j<=n; j++){

           System.out.print(p +" ");

        }

        System.out.println();

     }

  }

}

6. Write a python program to print following diamond number pattern: 

Code: Number Patterns | Java for EmSAT Achieve

public class CharacterPattern

{

    public static void main(String[] args) 

    {

       int n= 5;

       for(int i=1, p= 1; i<=n; i++, p++){

          for(int j=i; j<=n; j++){

              System.out.print(" ");

          }

          for(int j=1; j<i; j++){

              System.out.print(p +" ");

          }

          for(int j=1; j<=i; j++){

             System.out.print(p +" ");

          }

          System.out.println();

      }

      for(int i=1, p=5; i<=n; i++, p--){

          for(int j=1; j<=i; j++){

             System.out.print(" ");

          }

          for(int j=i; j<n; j++){

             System.out.print(p +" ");

          }

          for(int j=i; j<=n; j++){

             System.out.print(p +" ");

          }

          System.out.println();

      }

   }

}

7. Write a python program to print number pattern: 

Code: Number Patterns | Java for EmSAT Achieve

public class CharacterPattern

{

   public static void main(String[] args) 

   {

      int n=5;

      for(int i=1; i<=n; i++){

         int p=1;

         for(int j=1; j<=i; j++){

            System.out.print(p++ +" ");

         }

         System.out.println();

     }

   }

}

8. Write a python code to print following number pattern

Code: Number Patterns | Java for EmSAT Achieve

public class CharacterPattern

{

    public static void main(String[] args) 

    {

        int n= 5;

        for(int i=1; i<=n; i++){

           int p =1;

           for(int j=1; j<=i; j++){

              System.out.print(" ");

           }

           for(int j=i; j<=n; j++){

              System.out.print(p++ +" ");

           }

           System.out.println();

       }

   }

}

9. Write a python code to print following number hill pattern: 

Code: Number Patterns | Java for EmSAT Achieve

public class CharacterPattern 

   public static void main(String[] args) 

   {  

      int n= 5; 

      for(int i=1; i<=n; i++){ 

         int p =1; 

         for(int j=i; j<=n; j++){ 

            System.out.print(" "); 

         } 

         for(int j=1; j<i; j++){ 

            System.out.print(p++ +" "); 

         } 

         for(int j=1; j<=i; j++){ 

            System.out.print(p++ +" "); 

         } 

         System.out.println(); 

      } 

   } 

}

10. Write a python code to print following number pattern: 
Code: Number Patterns | Java for EmSAT Achieve

public class CharacterPattern 

{

   public static void main(String[] args)

   { 

      int n=5;

      for(int i=1; i<=n; i++){

         int p=5;

         for(int j=1; j<=i; j++){ 

            System.out.print(p – +" ");

         }

         System.out.println();

      }

   }

}

11. Write a python code to print following number pattern: 

Code: Number Patterns | Java for EmSAT Achieve

public class CharacterPattern

{

    public static void main(String[] args) 

    {

        int n=5;

        for(int i=1,k=n; i<=n;i++,k--){

           int p=k;

           for(int j=1; j<=i; j++){

              System.out.print(" ");

           }

           for(int j=i; j<=n; j++){

              System.out.print(p – +" ");

           }

           System.out.println();

       }

   }

}

12. Write a python code to print hill pattern with numbers: 

Code: Number Patterns | Java for EmSAT Achieve

public class CharacterPattern

{

   public static void main(String[] args) 

   {

       int n= 5;

       for(int i=1; i<=n; i++){

          int p =1;

          for(int j=i; j<=n; j++){

             System.out.print(" ");

          }

          for(int j=1; j<i; j++){

             System.out.print(p++ +" ");

          }

          for(int j=1; j<=i; j++){

             System.out.print(p – +" ");

          }

          System.out.println();

      }

   }

}

13. Write a python code to print following number pattern: 

Code: Number Patterns | Java for EmSAT Achieve

public class CharacterPattern

{

   public static void main(String[] args) 

   {

      int n=4, p=1;

      for(int i=1; i<=n; i++){

         for(int j=1; j<=i; j++){

            System.out.print(p++" ");

         }

         System.out.println();

      }

   }

}

The document Code: Number Patterns | Java for EmSAT Achieve is a part of the EmSAT Achieve Course Java for EmSAT Achieve.
All you need of EmSAT Achieve at this link: EmSAT Achieve
60 videos|37 docs|12 tests

Top Courses for EmSAT Achieve

60 videos|37 docs|12 tests
Download as PDF
Explore Courses for EmSAT Achieve exam

Top Courses for EmSAT Achieve

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

Code: Number Patterns | Java for EmSAT Achieve

,

Viva Questions

,

Semester Notes

,

past year papers

,

Free

,

pdf

,

MCQs

,

Previous Year Questions with Solutions

,

Sample Paper

,

Extra Questions

,

Code: Number Patterns | Java for EmSAT Achieve

,

mock tests for examination

,

Important questions

,

ppt

,

practice quizzes

,

Exam

,

Code: Number Patterns | Java for EmSAT Achieve

,

Objective type Questions

,

study material

,

Summary

,

video lectures

,

shortcuts and tricks

;