Top 100 Codes

PrepInsta Top 100 Codes

Below You will find some of the most important codes in languages like C, C++ and Java. These codes are of prime importance for college semester exams and also for various online tests and interviews of the companies offering placements within varying range in LPA.

These codes are very important since these will help you clear your basic concepts in various languages.

coding (3)

Important Codes related to Arrays

  • Find Smallest Element in an Array : C | C++ | Java | Python
  • Find Second Smallest Element in an Array : C | C++ | Java | Python
  • Find Largest element in an array : C | C++ | Java | Python
  • Find the Smallest and largest element in an array : C | C++ | Java | Python
  • Calculate the sum of elements in an array : C | C++ | Java | Python
  • Reverse an Array : C | C++ | Java | Python
  • Sort first half in ascending order and second half in descending : C | C++ | Java | Python
  • Sort the elements of an array : C | C++ | Java | Python
  • Finding the frequency of elements in an array : C | C++ | Java | Python
  • Finding the Longest Palindrome in an Array : C | C++ | Java| Python
  • Counting Distinct Elements in an Array : C | C++ | Java| Python
  • Finding  Repeating elements in an Array : C | C++ | Java | Python
  • Finding Non Repeating elements in an Array : C | C++ | Java | Python
  • Removing Duplicate elements from an array : C | C++ | Java
  • Finding Minimum scalar product of two vectors : C | C++ | Java | Python
  • Finding Maximum scalar product of two vectors in an array : C | C++ | Java | Python
  • Counting the number of even and odd elements in an array : C | C++ | Java | Python
  • Find all Symmetric pairs in an array : C | C++ | Java | Python
  • Find maximum product sub-array in a given array : C | C++ | Java | Python
  • Finding Arrays are disjoint or not : C | C++ | Java | Python
  • Determine Array is a subset of another array or not : C | C++ | Java | Python
  • Determine can all numbers of an array be made equal : C | C++ | Java | Python
  • Finding Minimum sum of absolute difference of given array : C | C++ | Java | Python
  • Sorting elements of an array by frequency : C | C++ | Java | Python
  • Sort an array according to the order defined by another array : C | C++ | Java | Python
  • Replace each element of the array by its rank in the array : C | C++ | Java | Python
  • Finding equilibrium index of an array : C | C++ | Java| Python
  • Rotation of elements of array- left and right : C | C++ | Java| Python
  • Block swap algorithm for array rotation : C | C++ | Java| Python
  • Juggling algorithm for array rotation : C | C++ | Java | Python
  • Finding Circular rotation of an array by K positions : C | C++ | Java | Python

You can find the below Programs in all languages

array
Operations on Strings

Operations on Strings

  • Length of the string without using strlen() function : C | C++ | Java | Python
  • Toggle each character in a string : C | C++ | Java | Python
  • Count the number of vowels : C | C++ | Java | Python
  • Remove the vowels from a String : C | C++ | Java | Python
  • Check if the given string is Palindrome or not : C | C++ | Java | Python
  • Print the given string in reverse order : C | C++ | Java | Python
  • Remove all characters from string except alphabets : C | C++ | Java | Python
  • Remove spaces from a string : C | C++ | Java | Python
  • Remove brackets from an algebraic expression : C | C++ | Java | Python
  • Count the sum of numbers in a string : C | C++ | Java | Python
  • Capitalize the first and last character of each word of a string : C | C++ | Java | Python
  • Calculate frequency of characters in a string : C | C++ | Java | Python
  • Find non-repeating characters in a string : C | C++ | JAVA | Python
  • Check if two strings are Anagram or not : C | C++ | Java | Python
  • Replace a sub-string in a string: C | C++ | Java | Python
  • Count common sub-sequence in two strings : C | C++ | Java | Python
  • Check if two strings match where one string contains wildcard characters : C | C++ | Java | Python

Pattern Printing

array
           ****
           ****
           ****
           ****

Square Star Pattern

Difficulty – ★

Checkout code for this program –

           ****
           *  *
           *  *
           ****

Hollow Square Star Pattern

Difficulty – ★ and 1/2

Checkout code for this program –

           ****
            ****
             ****
              ****

Rhombus Star Pattern

Difficulty – ★★

Checkout code for this program –

           ******
           ******
           ******
           ******

Rectangle Star Pattern

Difficulty – ★

Checkout code for this program –

           ******
           *    *
           *    *
           ******

Hollow Rectangle Star Pattern

Difficulty – ★ and 1/2

Checkout code for this program –

           ******
            ******
             ******
              ******

Parallelogram Star Pattern

Difficulty – ★★

Checkout code for this program –

           ****
          ****
         ****
        ****

Mirrored Rhombus Star Pattern

Difficulty – ★★ and 1/2

Checkout code for this program –

           *
           **
           ***
           ****

Triangle Star Pattern

Difficulty – ★ and 1/2

              *
             ***
            *****
           *******

Pyramid Star Pattern

Difficulty – ★★

              *
             * *
            *   *
           *******

Hollow Pyramid Star Pattern

Difficulty – ★★

           *******
            *****
             ***
              *

Inverted Pyramid Star Pattern

Difficulty – ★★

           *******
            *   *
             * *
              *

Inverted Hollow Pyramid Star Pattern

Difficulty – ★★ and 1/2

           *
           **
           ***
           ****
           ***
           **
           *
Half Diamond Star Pattern
              *
             **
            ***
           ****
            ***
             **
              *

Half Diamond Star Pattern Inverted

             *
            ***
           *****
          *******
           *****
            ***
             *

Diamond Star Pattern

Number Pattern Printing Programs

           1111
           1111
           1111
           1111

Basic Square 1 Pattern

Checkout code for this program –

           1111
           2222
           3333
           4444

Basic Square incrementing Pattern

Checkout code for this program –

           333
           313
           323
           333

Internal varsity square Pattern

Checkout code for this program –

           1
           23
           456
           78910

Basic Right Triangle Number Pattern

Checkout code for this program –

           10987
           456
           32
           1

Basic Right Triangle Number Pattern (Inverted)

Checkout code for this program –

           6666
           555
           44
           3

Basic incrementing Triangle Pattern initialised = 3

Checkout code for this program –

           3
           44
           555
           6666
Basic incrementing Triangle Pattern(Inverted) initialised = 3 Checkout code for this program –
           3
           4 5
           6 7 8
           9 10 11 12
Basic double incrementing Triangle Pattern initialised = 3 Checkout code for this program –
           3
           44
           555
           6666
           555
           44
           3

Basic incrementing Diamond Pattern(Inverted) initialised = 3

Checkout code for this program –

            3
            45
            678
            9101112
            678
            45
            3

Basic double incrementing Triangle Pattern initialised = 3

Checkout code for this program –

           3
           54
           876
           1211109
           876
           54
           3

Basic incrementing Triangle Pattern(Inverted) initialised Mirrored = 3

Checkout code for this program –

           2
           33
           444
           5555
           5555
           444
           33
           2

Basic incrementing Diamond Pattern(Inverted Sandwich) initialised = 3

Checkout code for this program –

            2
            34
            567
            891011
            891011
            567
            34
            2

Basic double incrementing Triangle Pattern initialised Sandwich= 3

Checkout code for this program –

           2
           43
           765
           1110198
           1110198
           765
           43
           2

Basic incrementing Triangle Pattern(Inverted) initialised Mirrored Sandwich = 3

Checkout code for this program –

Number Star Mix Pattern

           1*2*3*4
           5*6*7*8
           9*10*11*12
           13*14*15*16

Basic incrementing Squared Number-Star Pattern 

Checkout code for this program

C | Java | Python

           13*14*15*16
           9*10*11*12
           5*6*7*8
           1*2*3*4

Basic incrementing inverted Squared Number-Star Pattern

Checkout code for this program

C | Java | Python

          1*2*3*4
          9*10*11*12
          5*6*7*8
          13*14*15*16

Basic incrementing Squared Number-Star Pattern + Basic incrementing inverted Squared Number-Star Pattern (alternate)

Checkout code for this program

C | Java | Python

          1*2*3*4
          9*10*11*12
          13*14*15*16
          5*6*7*8

Basic incrementing Squared Number-Star Pattern + Basic incrementing inverted Squared Number-Star Pattern (alternate)

Type 2

Checkout code for this program

C | Java | Python

          1*2*3*4
          9*10*11*12
          17*18*19*20
          13*14*15*16
          5*6*7*8

Basic incrementing Squared Number-Star Pattern + Basic incrementing inverted Squared Number-Star Pattern (alternate)

Type 3

Checkout code for this program

C | Java | Python

          4*3*2*1
          12*11*10*9
          8*7*6*5
          16*15*14*13

Basic incrementing Squared Number-Star Pattern Mirrored + Basic incrementing inverted Squared Number-Star Pattern Mirrored (alternate)

Checkout code for this program

C | Java | Python

           1
           2*3
           4*5*6
           7*8*9*10

Basic incrementing Triangle Pattern

Checkout code for this program

C | Java | Python

           7*8*9*10
           4*5*6
           2*3
           1

Basic incrementing Triangle Pattern

Checkout code for this program

C | Java | Python

           1
           4*5*6
           2*3
           7*8*9*10

Basic incrementing Triangle Pattern + Inverted (Mix)

Checkout code for this program

C | Java | Python

           1
           3*2
           6*5*4
           10*9*8*7

Basic incrementing mirrored Triangle Pattern

Checkout code for this program

C | Java | Python

           10*9*8*7
           6*5*4
           3*2
           1

Basic incrementing inverted mirrored Triangle Pattern

Checkout code for this program

C | Java | Python

           1
           4*5*6
           2*3
           7*8*9*10

Basic incrementing Triangle Pattern + Inverted (Mix)

Checkout code for this program

C | Java | Python

           1
           2*2
           3*3*3
           4*4*4*4
           3*3*3
           2*2
           1

Basic Diamond Number Star Pattern

Checkout code for this program

C | Java | Python

           1
           2*2
           3*3*3
           4*4*4*4
           4*4*4*4
           3*3*3
           2*2
           1

Basic Diamond Number Star Pattern (Sandwich)

Checkout code for this program

C | Java | Python

           4*4*4*4
           3*3*3
           2*2
           1
           1
           2*2
           3*3*3
           4*4*4*4

Basic Diamond Number Star Pattern (Sandwich Inverted)

Checkout code for this program

C | Java | Python

           2
           3*3
           4*4*4
           3*3
           2

Basic Diamond Number Star Pattern initialised

Checkout code for this program

C | Java | Python

           2
           3*3
           4*4*4
           4*4*4
           3*3
           2

Basic Diamond Number Star Pattern (Sandwich)

Checkout code for this program

C | Java | Python

           6*6*6*6
           5*5*5
           4*4
           3
           3
           4*4
           5*5*5
           6*6*6*6

Basic Diamond Number Star Pattern (Sandwich Inverted)

Checkout code for this program

C | Java | Python