Skip to main content

Display Wave Patterns

In this Wave Pattern series, you will view the solution of following basic wave patterns.

[A] Wave pattern [B] Wave pattern [C] Wave pattern [D] Wave Pattern

Here given code implementation process.

//C Program 
//Display Wave Patterns
#include <stdio.h>

#include <stdlib.h>

//display space
void space(int size)
{
  for (int i = 0; i < size; ++i)
  {
    printf(" ");
  }
}
//Displaying of wave pattern in given size
void wave_pattern(int row,int column)
{

  if(row<=0 || column<=0 )
  {
    //When get a invalid size
    return;
  }
  printf("\nHeight : %d  Width : %d\n\n",row,column );
  //Display bottom half result
  for (int i = 0; i < row; ++i)
  {
    for (int j = 0; j < column  ; ++j)
    {
      //Display result
      space(i);

      printf("\\");
      
      space((row-i-1)*2);
      printf("/");
      space(i);

    }
    //include new line
    printf("\n");
  }
  printf("\n");
 
}
int main() {
    //Test Cases
    wave_pattern(6,3);
    wave_pattern(3,8);
    wave_pattern(8,3);
   
 return 0;
}

Output

Height : 6  Width : 3

\          /\          /\          /
 \        /  \        /  \        /
  \      /    \      /    \      /
   \    /      \    /      \    /
    \  /        \  /        \  /
     \/          \/          \/


Height : 3  Width : 8

\    /\    /\    /\    /\    /\    /\    /\    /
 \  /  \  /  \  /  \  /  \  /  \  /  \  /  \  /
  \/    \/    \/    \/    \/    \/    \/    \/


Height : 8  Width : 3

\              /\              /\              /
 \            /  \            /  \            /
  \          /    \          /    \          /
   \        /      \        /      \        /
    \      /        \      /        \      /
     \    /          \    /          \    /
      \  /            \  /            \  /
       \/              \/              \/
/*
  C++ Program
  Display Wave Patterns
*/
#include<iostream>
using namespace std;
class MyPattern {
  public:

    //display space
    void space(int size) {
      for (int i = 0; i < size; ++i) {
        cout << " ";
      }
    }
  //Displaying of wave pattern in given size
  void wave_pattern(int row, int column) {
    if (row <= 0 || column <= 0) {
      //When get a invalid size

      return;
    }
    cout << "\nHeight : " << row << " Width : " << column << "\n\n";
    //Display bottom half result

    for (int i = 0; i < row; ++i) {
      for (int j = 0; j < column; ++j) {
        //Display result
        this->space(i);
        cout << "\\";
        this->space((row - i - 1) *2);
        cout << "/";
        this->space(i);
      }
      //include new line

      cout << "\n";
    }
    cout << "\n";
  }
};
int main() {
  MyPattern obj =  MyPattern();
  //Test Cases
  obj.wave_pattern(6, 3);
  obj.wave_pattern(3, 8);
  obj.wave_pattern(8, 3);
  return 0;
}

Output

Height : 6 Width : 3

\          /\          /\          /
 \        /  \        /  \        /
  \      /    \      /    \      /
   \    /      \    /      \    /
    \  /        \  /        \  /
     \/          \/          \/


Height : 3 Width : 8

\    /\    /\    /\    /\    /\    /\    /\    /
 \  /  \  /  \  /  \  /  \  /  \  /  \  /  \  /
  \/    \/    \/    \/    \/    \/    \/    \/


Height : 8 Width : 3

\              /\              /\              /
 \            /  \            /  \            /
  \          /    \          /    \          /
   \        /      \        /      \        /
    \      /        \      /        \      /
     \    /          \    /          \    /
      \  /            \  /            \  /
       \/              \/              \/
/*
  Java Program
  Display Wave Patterns
*/

public class MyPattern {
 

  //display space
  public void space(int size)
  {
    for (int i = 0; i < size; ++i)
    {
      System.out.print(" ");
    }
  }
  //Displaying of wave pattern in given size
  public void wave_pattern(int row,int column)
  {

    if(row<=0 || column<=0 )
    {
      //When get a invalid size
      return;
    }
    System.out.print("\nHeight : "+row+"  Width : "+column+"\n\n");
    //Display bottom half result
    for (int i = 0; i < row; ++i)
    {
      for (int j = 0; j < column  ; ++j)
      {
        //Display result
        space(i);

        System.out.print("\\");
        
        space((row-i-1)*2);
        System.out.print("/");
        space(i);

      }
      //include new line
      System.out.print("\n");
    }
    System.out.print("\n");
   
  }
  public static void main(String[] args) {

    MyPattern obj = new MyPattern();

    //Test Cases
    obj.wave_pattern(6,3);
    obj.wave_pattern(3,8);
    obj.wave_pattern(8,3);
  }
}

Output

Height : 6 Width : 3

\          /\          /\          /
 \        /  \        /  \        /
  \      /    \      /    \      /
   \    /      \    /      \    /
    \  /        \  /        \  /
     \/          \/          \/


Height : 3 Width : 8

\    /\    /\    /\    /\    /\    /\    /\    /
 \  /  \  /  \  /  \  /  \  /  \  /  \  /  \  /
  \/    \/    \/    \/    \/    \/    \/    \/


Height : 8 Width : 3

\              /\              /\              /
 \            /  \            /  \            /
  \          /    \          /    \          /
   \        /      \        /      \        /
    \      /        \      /        \      /
     \    /          \    /          \    /
      \  /            \  /            \  /
       \/              \/              \/
/*
  C# Program
  Display Wave Patterns
*/
using System;

public class MyPattern {
  //display space
  public void space(int size) {
    for (int i = 0; i < size; ++i) {
      Console.Write(" ");
    }
  }
  //Displaying of wave pattern in given size
  public void wave_pattern(int row, int column) {
    if (row <= 0 || column <= 0) {
      return;
    }
    Console.Write("\nHeight : " + row + " Width : " + column + "\n\n");
    //Display bottom half result

    for (int i = 0; i < row; ++i) {
      for (int j = 0; j < column; ++j) {
        space(i);
        Console.Write("\\");
        space((row - i - 1) * 2);
        Console.Write("/");
        space(i);
      }
      Console.Write("\n");
    }
    Console.Write("\n");
  }
  public static void Main(String[] args) {
    MyPattern obj = new MyPattern();
    obj.wave_pattern(6, 3);
    obj.wave_pattern(3, 8);
    obj.wave_pattern(8, 3);
  }
}

Output

Height : 6 Width : 3

\          /\          /\          /
 \        /  \        /  \        /
  \      /    \      /    \      /
   \    /      \    /      \    /
    \  /        \  /        \  /
     \/          \/          \/


Height : 3 Width : 8

\    /\    /\    /\    /\    /\    /\    /\    /
 \  /  \  /  \  /  \  /  \  /  \  /  \  /  \  /
  \/    \/    \/    \/    \/    \/    \/    \/


Height : 8 Width : 3

\              /\              /\              /
 \            /  \            /  \            /
  \          /    \          /    \          /
   \        /      \        /      \        /
    \      /        \      /        \      /
     \    /          \    /          \    /
      \  /            \  /            \  /
       \/              \/              \/
<?php
/*
  Php Program
  Display Wave Patterns
*/
class MyPattern {
  //Display space
  public  function space($size) {
    for ($i = 0; $i < $size; ++$i) {
      echo(" ");
    }
  }
  //Displaying of wave pattern in given size
  public  function wave_pattern($row, $column) {
    if ($row <= 0 || $column <= 0) {
      return;
    }
    echo("\nHeight : ". $row ." Width : ". $column ."\n\n");
    //Display bottom half result
    for ($i = 0; $i < $row; ++$i) {
      for ($j = 0; $j < $column; ++$j) {
        //Display result
        $this->space($i);
        echo("\\");
        $this->space(($row - $i - 1) *2);
        echo("/");
        $this->space($i);
      }
      //include new line
      echo("\n");
    }
    echo("\n");
  }
}

function main() {
  $obj = new MyPattern();
  //Test Cases
  $obj->wave_pattern(6, 3);
  $obj->wave_pattern(3, 8);
  $obj->wave_pattern(8, 3);

}
main();

Output

Height : 6 Width : 3

\          /\          /\          /
 \        /  \        /  \        /
  \      /    \      /    \      /
   \    /      \    /      \    /
    \  /        \  /        \  /
     \/          \/          \/


Height : 3 Width : 8

\    /\    /\    /\    /\    /\    /\    /\    /
 \  /  \  /  \  /  \  /  \  /  \  /  \  /  \  /
  \/    \/    \/    \/    \/    \/    \/    \/


Height : 8 Width : 3

\              /\              /\              /
 \            /  \            /  \            /
  \          /    \          /    \          /
   \        /      \        /      \        /
    \      /        \      /        \      /
     \    /          \    /          \    /
      \  /            \  /            \  /
       \/              \/              \/
/*
  Node Js Program
  Display Wave Patterns
*/
class MyPattern {
  //display space
  space(size) {
    for (var i = 0; i < size; ++i) {
      process.stdout.write(" ");
    }
  }

  //Displaying of wave pattern in given size
  wave_pattern(row, column) {
    if (row <= 0 || column <= 0) {
      return;
    }

    process.stdout.write("\nHeight : " + row + " Width : " + column + "\n\n");
    //Display bottom half result
    for (var i = 0; i < row; ++i) {
      for (var j = 0; j < column; ++j) {
        //Display result
        this.space(i);
        process.stdout.write("\\");
        this.space((row - i - 1) *2);
        process.stdout.write("/");
        this.space(i);
      }

      //include new line
      process.stdout.write("\n");
    }

    process.stdout.write("\n");
  }
}

function main(args) {
  var obj = new MyPattern();
  //Test Cases
  obj.wave_pattern(6, 3);
  obj.wave_pattern(3, 8);
  obj.wave_pattern(8, 3);
}

main();

Output

Height : 6 Width : 3

\          /\          /\          /
 \        /  \        /  \        /
  \      /    \      /    \      /
   \    /      \    /      \    /
    \  /        \  /        \  /
     \/          \/          \/


Height : 3 Width : 8

\    /\    /\    /\    /\    /\    /\    /\    /
 \  /  \  /  \  /  \  /  \  /  \  /  \  /  \  /
  \/    \/    \/    \/    \/    \/    \/    \/


Height : 8 Width : 3

\              /\              /\              /
 \            /  \            /  \            /
  \          /    \          /    \          /
   \        /      \        /      \        /
    \      /        \      /        \      /
     \    /          \    /          \    /
      \  /            \  /            \  /
       \/              \/              \/
#   Python 3 Program
#   Display Wave Patterns

class MyPattern :
  # display space
  def space(self, size) :
    i = 0
    while (i < size) :
      print(" ", end = "")
      i += 1
    
  
  # Displaying of wave pattern in given size
  def wave_pattern(self, row, column) :
    if (row <= 0 or column <= 0) :
      return
    
    print("\nHeight : ", row ," Width : ", column ,"\n\n", end = "")
    # Display bottom half result
    i = 0
    while (i < row) :
      j = 0
      while (j < column) :
        self.space(i)
        print("\\", end = "")
        self.space((row - i - 1) * 2)
        print("/", end = "")
        self.space(i)
        j += 1
      
      print("\n", end = "")
      i += 1
    
    print("\n", end = "")
  

def main() :
  obj = MyPattern()
  obj.wave_pattern(6, 3)
  obj.wave_pattern(3, 8)
  obj.wave_pattern(8, 3)


if __name__ == "__main__":
  main()

Output

Height :  6  Width :  3

\          /\          /\          /
 \        /  \        /  \        /
  \      /    \      /    \      /
   \    /      \    /      \    /
    \  /        \  /        \  /
     \/          \/          \/


Height :  3  Width :  8

\    /\    /\    /\    /\    /\    /\    /\    /
 \  /  \  /  \  /  \  /  \  /  \  /  \  /  \  /
  \/    \/    \/    \/    \/    \/    \/    \/


Height :  8  Width :  3

\              /\              /\              /
 \            /  \            /  \            /
  \          /    \          /    \          /
   \        /      \        /      \        /
    \      /        \      /        \      /
     \    /          \    /          \    /
      \  /            \  /            \  /
       \/              \/              \/
#   Ruby Program
#   Display Wave Patterns

class MyPattern 
   # display space
  def space(size) 
    i = 0
    while (i < size) 
      print(" ")
      i += 1
    end
  end
   # Displaying of wave pattern in given size
  def wave_pattern(row, column) 
    if (row <= 0 || column <= 0) 
      return
    end
    print("\nHeight  :", row ," Width  :", column ,"\n\n")
     # Display bottom half result
    i = 0
    while (i < row) 
      j = 0
      while (j < column) 
        self.space(i)
        print("\\")
        self.space((row - i - 1) * 2)
        print("/")
        self.space(i)
        j += 1
      end
      print("\n")
      i += 1
    end
    print("\n")
  end
end
def main() 
  obj = MyPattern.new()
  obj.wave_pattern(6, 3)
  obj.wave_pattern(3, 8)
  obj.wave_pattern(8, 3)
end
main()

Output

Height  :6 Width  :3

\          /\          /\          /
 \        /  \        /  \        / 
  \      /    \      /    \      /  
   \    /      \    /      \    /   
    \  /        \  /        \  /    
     \/          \/          \/     


Height  :3 Width  :8

\    /\    /\    /\    /\    /\    /\    /\    /
 \  /  \  /  \  /  \  /  \  /  \  /  \  /  \  / 
  \/    \/    \/    \/    \/    \/    \/    \/  


Height  :8 Width  :3

\              /\              /\              /
 \            /  \            /  \            / 
  \          /    \          /    \          /  
   \        /      \        /      \        /   
    \      /        \      /        \      /    
     \    /          \    /          \    /     
      \  /            \  /            \  /      
       \/              \/              \/       

/*
  Scala Program
  Display Wave Patterns
*/
class MyPattern {
  //display space
  def space(size: Int): Unit = {
    var i: Int = 0;
    while (i < size) {
      print(" ");
      i += 1;
    }
  }
  //Displaying of wave pattern in given size
  def wave_pattern(row: Int, column: Int): Unit = {
    if (row <= 0 || column <= 0) {
      return;
    }
    print("\nHeight : " + row + " Width : " + column + "\n\n");

    //Display bottom half result
    var i: Int = 0;
    while (i < row) {
      var j: Int = 0;
      while (j < column) {
        this.space(i);
        print("\\");
        this.space((row - i - 1) * 2);
        print("/");
        this.space(i);
        j += 1;
      }
      print("\n");
      i += 1;
    }
    print("\n");
  }
}
object Main {
  def main(args: Array[String]): Unit = {
    val obj: MyPattern = new MyPattern();
    obj.wave_pattern(6, 3);
    obj.wave_pattern(3, 8);
    obj.wave_pattern(8, 3);
  }
}

Output

Height : 6 Width : 3

\          /\          /\          /
 \        /  \        /  \        /
  \      /    \      /    \      /
   \    /      \    /      \    /
    \  /        \  /        \  /
     \/          \/          \/


Height : 3 Width : 8

\    /\    /\    /\    /\    /\    /\    /\    /
 \  /  \  /  \  /  \  /  \  /  \  /  \  /  \  /
  \/    \/    \/    \/    \/    \/    \/    \/


Height : 8 Width : 3

\              /\              /\              /
 \            /  \            /  \            /
  \          /    \          /    \          /
   \        /      \        /      \        /
    \      /        \      /        \      /
     \    /          \    /          \    /
      \  /            \  /            \  /
       \/              \/              \/
/*
  Swift Program
  Display Wave Patterns
*/
class MyPattern {
  //display space
  func space(_ size: Int) {
    var i = 0;
    while (i < size) {
      print(" ", terminator: "");
      i += 1;
    }
  }
  //Displaying of wave pattern in given size
  func wave_pattern(_ row: Int, _ column: Int) {
    if (row <= 0 || column <= 0) {
      return;
    }
    print("\nHeight : ", row ," Width : ", column ,"\n\n", terminator: "");
    //Display bottom half result
    var i = 0;
    while (i < row) {
      var j = 0;
      while (j < column) {
        self.space(i);
        print("\\", terminator: "");
        self.space((row - i - 1) * 2);
        print("/", terminator: "");
        self.space(i);
        j += 1;
      }
      print("\n", terminator: "");
      i += 1;
    }
    print("\n", terminator: "");
  }
}
func main() {
  let obj = MyPattern();
  obj.wave_pattern(6, 3);
  obj.wave_pattern(3, 8);
  obj.wave_pattern(8, 3);
}
main();

Output

Height :  6  Width :  3

\          /\          /\          /
 \        /  \        /  \        /
  \      /    \      /    \      /
   \    /      \    /      \    /
    \  /        \  /        \  /
     \/          \/          \/


Height :  3  Width :  8

\    /\    /\    /\    /\    /\    /\    /\    /
 \  /  \  /  \  /  \  /  \  /  \  /  \  /  \  /
  \/    \/    \/    \/    \/    \/    \/    \/


Height :  8  Width :  3

\              /\              /\              /
 \            /  \            /  \            /
  \          /    \          /    \          /
   \        /      \        /      \        /
    \      /        \      /        \      /
     \    /          \    /          \    /
      \  /            \  /            \  /
       \/              \/              \/
//C Program 
//Display Wave Patterns
#include <stdio.h>

#include <stdlib.h>

//display space
void space(int size)
{
  for (int i = 0; i < size; ++i)
  {
    printf(" ");
  }
}
//Displaying of wave pattern in given size
void wave_pattern(int row,int column)
{
  if(row<=0 || column<=0)
  {
    //When get a invalid size
    return;
  }
  printf("\nHeight : %d  Width : %d\n\n",row,column );
  
  row-=1;
  column-=1;

  for (int i = 0; i <= row; ++i)
  {
    //display the wave in given column and row
    for (int j = 0; j <= column  ; ++j)
    {
      //Display result
      space(row-i);

      printf("/");
      //include i*i space
      space(i+i);
      printf("\\");
      //include size-i space
      space(row-i);

    }
    //include new line
    printf("\n");


  }
}
int main() {
    //Test Cases
    wave_pattern(5,3);
    wave_pattern(3,4);
    wave_pattern(7,6);
    wave_pattern(7,7);
 return 0;
}

Output

Height : 5  Width : 3

    /\        /\        /\
   /  \      /  \      /  \
  /    \    /    \    /    \
 /      \  /      \  /      \
/        \/        \/        \

Height : 3  Width : 4

  /\    /\    /\    /\
 /  \  /  \  /  \  /  \
/    \/    \/    \/    \

Height : 7  Width : 6

      /\            /\            /\            /\            /\            /\
     /  \          /  \          /  \          /  \          /  \          /  \
    /    \        /    \        /    \        /    \        /    \        /    \
   /      \      /      \      /      \      /      \      /      \      /      \
  /        \    /        \    /        \    /        \    /        \    /        \
 /          \  /          \  /          \  /          \  /          \  /          \
/            \/            \/            \/            \/            \/            \

Height : 7  Width : 7

      /\            /\            /\            /\            /\            /\            /\
     /  \          /  \          /  \          /  \          /  \          /  \          /  \
    /    \        /    \        /    \        /    \        /    \        /    \        /    \
   /      \      /      \      /      \      /      \      /      \      /      \      /      \
  /        \    /        \    /        \    /        \    /        \    /        \    /        \
 /          \  /          \  /          \  /          \  /          \  /          \  /          \
/            \/            \/            \/            \/            \/            \/            \
/*
  C++ Program
  Display Wave Patterns
*/
#include<iostream>

using namespace std;
class MyPattern {
  public:

    //display space
    void space(int size) {
      for (int i = 0; i < size; ++i) {
        cout << " ";
      }
    }
  //Displaying of wave pattern in given size
  void wave_pattern(int row, int column) {
    if (row <= 0 || column <= 0) {
      //When get a invalid size

      return;
    }
    cout << "\nHeight : " << row << " Width : " << column << "\n\n";
    row -= 1;
    column -= 1;
    for (int i = 0; i <= row; ++i) {
      //display the wave in given column and row

      for (int j = 0; j <= column; ++j) {
        //Display result
        this->space(row - i);
        cout << "/";
        //include i*i space
        this->space(i + i);
        cout << "\\";
        //include size-i space
        this->space(row - i);
      }
      //include new line

      cout << "\n";
    }
  }
};
int main() {
  MyPattern obj =  MyPattern();
  //Test Cases
  obj.wave_pattern(5, 3);
  obj.wave_pattern(3, 4);
  obj.wave_pattern(7, 6);
  obj.wave_pattern(7, 7);
  return 0;
}

Output

Height : 5 Width : 3

    /\        /\        /\
   /  \      /  \      /  \
  /    \    /    \    /    \
 /      \  /      \  /      \
/        \/        \/        \

Height : 3 Width : 4

  /\    /\    /\    /\
 /  \  /  \  /  \  /  \
/    \/    \/    \/    \

Height : 7 Width : 6

      /\            /\            /\            /\            /\            /\
     /  \          /  \          /  \          /  \          /  \          /  \
    /    \        /    \        /    \        /    \        /    \        /    \
   /      \      /      \      /      \      /      \      /      \      /      \
  /        \    /        \    /        \    /        \    /        \    /        \
 /          \  /          \  /          \  /          \  /          \  /          \
/            \/            \/            \/            \/            \/            \

Height : 7 Width : 7

      /\            /\            /\            /\            /\            /\            /\
     /  \          /  \          /  \          /  \          /  \          /  \          /  \
    /    \        /    \        /    \        /    \        /    \        /    \        /    \
   /      \      /      \      /      \      /      \      /      \      /      \      /      \
  /        \    /        \    /        \    /        \    /        \    /        \    /        \
 /          \  /          \  /          \  /          \  /          \  /          \  /          \
/            \/            \/            \/            \/            \/            \/            \
/*
  Java Program
  Display Wave Patterns
*/

public class MyPattern {
 
  //display space
  public void space(int size)
  {
    for (int i = 0; i < size; ++i)
    {
      System.out.print(" ");
    }
  }
  //Displaying of wave pattern in given size
  public void wave_pattern(int row,int column)
  {
    if(row<=0 || column<=0)
    {
      //When get a invalid size
      return;
    }
    System.out.print("\nHeight : "+row+"  Width : "+column+"\n\n");
    
    row-=1;
    column-=1;

    for (int i = 0; i <= row; ++i)
    {
      //display the wave in given column and row
      for (int j = 0; j <= column  ; ++j)
      {
        //Display result
        space(row-i);

        System.out.print("/");
        //include i*i space
        space(i+i);
        System.out.print("\\");
        //include size-i space
        space(row-i);

      }
      //include new line
      System.out.print("\n");


    }
  }
  public static void main(String[] args) {

    MyPattern obj = new MyPattern();
    //Test Cases
    obj.wave_pattern(5,3);
    obj.wave_pattern(3,4);
    obj.wave_pattern(7,6);
    obj.wave_pattern(7,7);
  }
}

Output

Height : 5 Width : 3

    /\        /\        /\
   /  \      /  \      /  \
  /    \    /    \    /    \
 /      \  /      \  /      \
/        \/        \/        \

Height : 3 Width : 4

  /\    /\    /\    /\
 /  \  /  \  /  \  /  \
/    \/    \/    \/    \

Height : 7 Width : 6

      /\            /\            /\            /\            /\            /\
     /  \          /  \          /  \          /  \          /  \          /  \
    /    \        /    \        /    \        /    \        /    \        /    \
   /      \      /      \      /      \      /      \      /      \      /      \
  /        \    /        \    /        \    /        \    /        \    /        \
 /          \  /          \  /          \  /          \  /          \  /          \
/            \/            \/            \/            \/            \/            \

Height : 7 Width : 7

      /\            /\            /\            /\            /\            /\            /\
     /  \          /  \          /  \          /  \          /  \          /  \          /  \
    /    \        /    \        /    \        /    \        /    \        /    \        /    \
   /      \      /      \      /      \      /      \      /      \      /      \      /      \
  /        \    /        \    /        \    /        \    /        \    /        \    /        \
 /          \  /          \  /          \  /          \  /          \  /          \  /          \
/            \/            \/            \/            \/            \/            \/            \
/*
  C# Program
  Display Wave Patterns
*/
using System;

public class MyPattern {
  //display space
  public void space(int size) {
    for (int i = 0; i < size; ++i) {
      Console.Write(" ");
    }
  }
  //Displaying of wave pattern in given size
  public void wave_pattern(int row, int column) {
    if (row <= 0 || column <= 0) {
      return;
    }
    Console.Write("\nHeight : " + row + " Width : " + column + "\n\n");
    row -= 1;
    column -= 1;
    for (int i = 0; i <= row; ++i) {
      //display the wave in given column and row

      for (int j = 0; j <= column; ++j) {
        space(row - i);
        Console.Write("/");
        space(i + i);
        Console.Write("\\");
        space(row - i);
      }
      Console.Write("\n");
    }
  }
  public static void Main(String[] args) {
    MyPattern obj = new MyPattern();
    obj.wave_pattern(5, 3);
    obj.wave_pattern(3, 4);
    obj.wave_pattern(7, 6);
    obj.wave_pattern(7, 7);
  }
}

Output

Height : 5 Width : 3

    /\        /\        /\
   /  \      /  \      /  \
  /    \    /    \    /    \
 /      \  /      \  /      \
/        \/        \/        \

Height : 3 Width : 4

  /\    /\    /\    /\
 /  \  /  \  /  \  /  \
/    \/    \/    \/    \

Height : 7 Width : 6

      /\            /\            /\            /\            /\            /\
     /  \          /  \          /  \          /  \          /  \          /  \
    /    \        /    \        /    \        /    \        /    \        /    \
   /      \      /      \      /      \      /      \      /      \      /      \
  /        \    /        \    /        \    /        \    /        \    /        \
 /          \  /          \  /          \  /          \  /          \  /          \
/            \/            \/            \/            \/            \/            \

Height : 7 Width : 7

      /\            /\            /\            /\            /\            /\            /\
     /  \          /  \          /  \          /  \          /  \          /  \          /  \
    /    \        /    \        /    \        /    \        /    \        /    \        /    \
   /      \      /      \      /      \      /      \      /      \      /      \      /      \
  /        \    /        \    /        \    /        \    /        \    /        \    /        \
 /          \  /          \  /          \  /          \  /          \  /          \  /          \
/            \/            \/            \/            \/            \/            \/            \
<?php
/*
  Php Program
  Display Wave Patterns
*/
class MyPattern {
  //display space
  public  function space($size) {
    for ($i = 0; $i < $size; ++$i) {
      echo(" ");
    }
  }
  //Displaying of wave pattern in given size
  public  function wave_pattern($row, $column) {
    if ($row <= 0 || $column <= 0) {
      return;
    }
    echo("\nHeight : ". $row ." Width : ". $column ."\n\n");
    $row -= 1;
    $column -= 1;
    for ($i = 0; $i <= $row; ++$i) {
      //display the wave in given column and row

      for ($j = 0; $j <= $column; ++$j) {
        //Display result
        $this->space($row - $i);
        echo("/");
        //include i*i space
        $this->space($i + $i);
        echo("\\");
        //include size-i space
        $this->space($row - $i);
      }
      //include new line

      echo("\n");
    }
  }
}

function main() {
  $obj = new MyPattern();
  //Test Cases
  $obj->wave_pattern(5, 3);
  $obj->wave_pattern(3, 4);
  $obj->wave_pattern(7, 6);
  $obj->wave_pattern(7, 7);

}
main();

Output

Height : 5 Width : 3

    /\        /\        /\
   /  \      /  \      /  \
  /    \    /    \    /    \
 /      \  /      \  /      \
/        \/        \/        \

Height : 3 Width : 4

  /\    /\    /\    /\
 /  \  /  \  /  \  /  \
/    \/    \/    \/    \

Height : 7 Width : 6

      /\            /\            /\            /\            /\            /\
     /  \          /  \          /  \          /  \          /  \          /  \
    /    \        /    \        /    \        /    \        /    \        /    \
   /      \      /      \      /      \      /      \      /      \      /      \
  /        \    /        \    /        \    /        \    /        \    /        \
 /          \  /          \  /          \  /          \  /          \  /          \
/            \/            \/            \/            \/            \/            \

Height : 7 Width : 7

      /\            /\            /\            /\            /\            /\            /\
     /  \          /  \          /  \          /  \          /  \          /  \          /  \
    /    \        /    \        /    \        /    \        /    \        /    \        /    \
   /      \      /      \      /      \      /      \      /      \      /      \      /      \
  /        \    /        \    /        \    /        \    /        \    /        \    /        \
 /          \  /          \  /          \  /          \  /          \  /          \  /          \
/            \/            \/            \/            \/            \/            \/            \
/*
  Node Js Program
  Display Wave Patterns
*/
class MyPattern {
  //display space
  space(size) {
    for (var i = 0; i < size; ++i) {
      process.stdout.write(" ");
    }
  }

  //Displaying of wave pattern in given size
  wave_pattern(row, column) {
    if (row <= 0 || column <= 0) {
      return;
    }

    process.stdout.write("\nHeight : " + row + " Width : " + column + "\n\n");
    row -= 1;
    column -= 1;
    for (var i = 0; i <= row; ++i) {
      //display the wave in given column and row

      for (var j = 0; j <= column; ++j) {
        //Display result
        this.space(row - i);
        process.stdout.write("/");
        //include i*i space
        this.space(i + i);
        process.stdout.write("\\");
        //include size-i space
        this.space(row - i);
      }

      //include new line

      process.stdout.write("\n");
    }
  }
}

function main(args) {
  var obj = new MyPattern();
  //Test Cases
  obj.wave_pattern(5, 3);
  obj.wave_pattern(3, 4);
  obj.wave_pattern(7, 6);
  obj.wave_pattern(7, 7);
}

main();

Output

Height : 5 Width : 3

    /\        /\        /\
   /  \      /  \      /  \
  /    \    /    \    /    \
 /      \  /      \  /      \
/        \/        \/        \

Height : 3 Width : 4

  /\    /\    /\    /\
 /  \  /  \  /  \  /  \
/    \/    \/    \/    \

Height : 7 Width : 6

      /\            /\            /\            /\            /\            /\
     /  \          /  \          /  \          /  \          /  \          /  \
    /    \        /    \        /    \        /    \        /    \        /    \
   /      \      /      \      /      \      /      \      /      \      /      \
  /        \    /        \    /        \    /        \    /        \    /        \
 /          \  /          \  /          \  /          \  /          \  /          \
/            \/            \/            \/            \/            \/            \

Height : 7 Width : 7

      /\            /\            /\            /\            /\            /\            /\
     /  \          /  \          /  \          /  \          /  \          /  \          /  \
    /    \        /    \        /    \        /    \        /    \        /    \        /    \
   /      \      /      \      /      \      /      \      /      \      /      \      /      \
  /        \    /        \    /        \    /        \    /        \    /        \    /        \
 /          \  /          \  /          \  /          \  /          \  /          \  /          \
/            \/            \/            \/            \/            \/            \/            \
#   Python 3 Program
#   Display Wave Patterns

class MyPattern :
  # display space
  def space(self, size) :
    i = 0
    while (i < size) :
      print(" ", end = "")
      i += 1
    
  
  # Displaying of wave pattern in given size
  def wave_pattern(self, row, column) :
    if (row <= 0 or column <= 0) :
      return
    
    print("\nHeight : ", row ," Width : ", column ,"\n\n", end = "")
    row -= 1
    column -= 1
    i = 0
    j = 0
    while (i <= row) :
      # display the wave in given column and row
      j = 0
      while (j <= column) :
        self.space(row - i)
        print("/", end = "")
        self.space(i + i)
        print("\\", end = "")
        self.space(row - i)
        j += 1
      
      print("\n", end = "")
      i += 1
    
  

def main() :
  obj = MyPattern()
  obj.wave_pattern(5, 3)
  obj.wave_pattern(3, 4)
  obj.wave_pattern(7, 6)
  obj.wave_pattern(7, 7)


if __name__ == "__main__":
  main()

Output

Height :  5  Width :  3

    /\        /\        /\
   /  \      /  \      /  \
  /    \    /    \    /    \
 /      \  /      \  /      \
/        \/        \/        \

Height :  3  Width :  4

  /\    /\    /\    /\
 /  \  /  \  /  \  /  \
/    \/    \/    \/    \

Height :  7  Width :  6

      /\            /\            /\            /\            /\            /\
     /  \          /  \          /  \          /  \          /  \          /  \
    /    \        /    \        /    \        /    \        /    \        /    \
   /      \      /      \      /      \      /      \      /      \      /      \
  /        \    /        \    /        \    /        \    /        \    /        \
 /          \  /          \  /          \  /          \  /          \  /          \
/            \/            \/            \/            \/            \/            \

Height :  7  Width :  7

      /\            /\            /\            /\            /\            /\            /\
     /  \          /  \          /  \          /  \          /  \          /  \          /  \
    /    \        /    \        /    \        /    \        /    \        /    \        /    \
   /      \      /      \      /      \      /      \      /      \      /      \      /      \
  /        \    /        \    /        \    /        \    /        \    /        \    /        \
 /          \  /          \  /          \  /          \  /          \  /          \  /          \
/            \/            \/            \/            \/            \/            \/            \
#   Ruby Program
#   Display Wave Patterns

class MyPattern 
   # display space
  def space(size) 
    i = 0
    while (i < size) 
      print(" ")
      i += 1
    end
  end
   # Displaying of wave pattern in given size
  def wave_pattern(row, column) 
    if (row <= 0 || column <= 0) 
      return
    end
    print("\nHeight  :", row ," Width  :", column ,"\n\n")
    row -= 1
    column -= 1
    i = 0
    j = 0
    while (i <= row) 
       # display the wave in given column and row
      j = 0
      while (j <= column) 
        self.space(row - i)
        print("/")
        self.space(i + i)
        print("\\")
        self.space(row - i)
        j += 1
      end
      print("\n")
      i += 1
    end
  end
end
def main() 
  obj = MyPattern.new()
  obj.wave_pattern(5, 3)
  obj.wave_pattern(3, 4)
  obj.wave_pattern(7, 6)
  obj.wave_pattern(7, 7)
end
main()

Output

Height  :5 Width  :3

    /\        /\        /\    
   /  \      /  \      /  \   
  /    \    /    \    /    \  
 /      \  /      \  /      \ 
/        \/        \/        \

Height  :3 Width  :4

  /\    /\    /\    /\  
 /  \  /  \  /  \  /  \ 
/    \/    \/    \/    \

Height  :7 Width  :6

      /\            /\            /\            /\            /\            /\      
     /  \          /  \          /  \          /  \          /  \          /  \     
    /    \        /    \        /    \        /    \        /    \        /    \    
   /      \      /      \      /      \      /      \      /      \      /      \   
  /        \    /        \    /        \    /        \    /        \    /        \  
 /          \  /          \  /          \  /          \  /          \  /          \ 
/            \/            \/            \/            \/            \/            \

Height  :7 Width  :7

      /\            /\            /\            /\            /\            /\            /\      
     /  \          /  \          /  \          /  \          /  \          /  \          /  \     
    /    \        /    \        /    \        /    \        /    \        /    \        /    \    
   /      \      /      \      /      \      /      \      /      \      /      \      /      \   
  /        \    /        \    /        \    /        \    /        \    /        \    /        \  
 /          \  /          \  /          \  /          \  /          \  /          \  /          \ 
/            \/            \/            \/            \/            \/            \/            \
/*
  Scala Program
  Display Wave Patterns
*/
class MyPattern {
  //display space
  def space(size: Int): Unit = {
    var i: Int = 0;
    while (i < size) {
      print(" ");
      i += 1;
    }
  }
  //Displaying of wave pattern in given size
  def wave_pattern(r: Int, c: Int): Unit = {
    if (r <= 0 || c <= 0) {
      return;
    }
    print("\nHeight : " + r + " Width : " + c + "\n\n");
    var row = r-1;
    var column = c-1;
    var i: Int = 0;
    var j: Int = 0;
    while (i <= row) {
      //display the wave in given column and row
      j = 0;
      while (j <= column) {
        this.space(row - i);
        print("/");
        this.space(i + i);
        print("\\");
        this.space(row - i);
        j += 1;
      }
      print("\n");
      i += 1;
    }
  }
}
object Main {
  def main(args: Array[String]): Unit = {
    val obj: MyPattern = new MyPattern();
    obj.wave_pattern(5, 3);
    obj.wave_pattern(3, 4);
    obj.wave_pattern(7, 6);
    obj.wave_pattern(7, 7);
  }
}

Output

Height : 5 Width : 3

    /\        /\        /\
   /  \      /  \      /  \
  /    \    /    \    /    \
 /      \  /      \  /      \
/        \/        \/        \

Height : 3 Width : 4

  /\    /\    /\    /\
 /  \  /  \  /  \  /  \
/    \/    \/    \/    \

Height : 7 Width : 6

      /\            /\            /\            /\            /\            /\
     /  \          /  \          /  \          /  \          /  \          /  \
    /    \        /    \        /    \        /    \        /    \        /    \
   /      \      /      \      /      \      /      \      /      \      /      \
  /        \    /        \    /        \    /        \    /        \    /        \
 /          \  /          \  /          \  /          \  /          \  /          \
/            \/            \/            \/            \/            \/            \

Height : 7 Width : 7

      /\            /\            /\            /\            /\            /\            /\
     /  \          /  \          /  \          /  \          /  \          /  \          /  \
    /    \        /    \        /    \        /    \        /    \        /    \        /    \
   /      \      /      \      /      \      /      \      /      \      /      \      /      \
  /        \    /        \    /        \    /        \    /        \    /        \    /        \
 /          \  /          \  /          \  /          \  /          \  /          \  /          \
/            \/            \/            \/            \/            \/            \/            \
/*
  Swift Program
  Display Wave Patterns
*/
class MyPattern {
  //display space
  func space(_ size: Int) {
    var i = 0;
    while (i < size) {
      print(" ", terminator: "");
      i += 1;
    }
  }
  //Displaying of wave pattern in given size
  func wave_pattern(_ r:  Int, _ c:  Int) {
    if (r <= 0 || c <= 0) {
      return;
    }
    print("\nHeight : ", r ," Width : ", c ,"\n\n", terminator: "");
    let row = r - 1;
        let column = c - 1;
    var i = 0;
    var j = 0;
    while (i <= row) {
      //display the wave in given column and row
      j = 0;
      while (j <= column) {
        self.space(row - i);
        print("/", terminator: "");
        self.space(i + i);
        print("\\", terminator: "");
        self.space(row - i);
        j += 1;
      }
      print("\n", terminator: "");
      i += 1;
    }
  }
}
func main() {
  let obj = MyPattern();
  obj.wave_pattern(5, 3);
  obj.wave_pattern(3, 4);
  obj.wave_pattern(7, 6);
  obj.wave_pattern(7, 7);
}
main();

Output

Height :  5  Width :  3

    /\        /\        /\
   /  \      /  \      /  \
  /    \    /    \    /    \
 /      \  /      \  /      \
/        \/        \/        \

Height :  3  Width :  4

  /\    /\    /\    /\
 /  \  /  \  /  \  /  \
/    \/    \/    \/    \

Height :  7  Width :  6

      /\            /\            /\            /\            /\            /\
     /  \          /  \          /  \          /  \          /  \          /  \
    /    \        /    \        /    \        /    \        /    \        /    \
   /      \      /      \      /      \      /      \      /      \      /      \
  /        \    /        \    /        \    /        \    /        \    /        \
 /          \  /          \  /          \  /          \  /          \  /          \
/            \/            \/            \/            \/            \/            \

Height :  7  Width :  7

      /\            /\            /\            /\            /\            /\            /\
     /  \          /  \          /  \          /  \          /  \          /  \          /  \
    /    \        /    \        /    \        /    \        /    \        /    \        /    \
   /      \      /      \      /      \      /      \      /      \      /      \      /      \
  /        \    /        \    /        \    /        \    /        \    /        \    /        \
 /          \  /          \  /          \  /          \  /          \  /          \  /          \
/            \/            \/            \/            \/            \/            \/            \
//C Program 
//Display Wave Patterns
#include <stdio.h>

#include <stdlib.h>

//display space
void space(int size)
{
  for (int i = 0; i < size; ++i)
  {
    printf(" ");
  }
}
//Displaying of wave pattern in given size
void wave_pattern(int r,int column)
{

  int row=(r/2);


  if(r<=0 || column<=0 )
  {
    //When get a invalid size
    return;
  }
  else if(r%2!=0)
  {
    printf("\nThe height is odd, to the height is increased by one");
    printf("\nHeight : %d  Width : %d\n\n",r+1,column );
    row+=1;
  }
  else
  {
     printf("\nHeight : %d  Width : %d\n\n",r,column );
  }
 
  
  //Display top half result
  for (int i = 0; i < row; ++i)
  {
    for (int j = 0; j < column  ; ++j)
    {
      //Display result
      space(row-i-1);

      printf("/");
      //include space
      space(i+i);
      printf("\\");
      //include size-i space
      space(row-i-1);

    }
    //include new line
    printf("\n");


  }
  //Display bottom half result
  for (int i = 0; i < row; ++i)
  {
    for (int j = 0; j < column  ; ++j)
    {
      //Display result
      space(i);

      printf("\\");
      //include space
      space((row-i-1)*2);
      printf("/");
      space(i);

    }
    //include new line
    printf("\n");
  }
 
}
int main() {
    //Test Cases
    wave_pattern(6,3);
    wave_pattern(3,8);
    wave_pattern(8,3);
   
 return 0;
}

Output

Height : 6  Width : 3

  /\    /\    /\
 /  \  /  \  /  \
/    \/    \/    \
\    /\    /\    /
 \  /  \  /  \  /
  \/    \/    \/

The height is odd, to the height is increased by one
Height : 4  Width : 8

 /\  /\  /\  /\  /\  /\  /\  /\
/  \/  \/  \/  \/  \/  \/  \/  \
\  /\  /\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/  \/  \/

Height : 8  Width : 3

   /\      /\      /\
  /  \    /  \    /  \
 /    \  /    \  /    \
/      \/      \/      \
\      /\      /\      /
 \    /  \    /  \    /
  \  /    \  /    \  /
   \/      \/      \/
/*
  C++ Program
  Display Wave Patterns
*/
#include<iostream>

using namespace std;
class MyPattern {
  public:

    //display space
    void space(int size) {
      for (int i = 0; i < size; ++i) {
        cout << " ";
      }
    }
  //Displaying of wave pattern in given size
  void wave_pattern(int r, int column) {
    int row = (r / 2);
    if (r <= 0 || column <= 0) {
      //When get a invalid size

      return;
    } else
    if (r % 2 != 0) {
      cout << "\nThe height is odd, to the height is increased by one";
      cout << "\nHeight : " << (r + 1) << " Width : " << column << "\n\n";
      row += 1;
    } else {
      cout << "\nHeight : " << r << " Width : " << column << "\n\n";
    }
    //Display top half result

    for (int i = 0; i < row; ++i) {
      for (int j = 0; j < column; ++j) {
        //Display result
        this->space(row - i - 1);
        cout << "/";
        //include space
        this->space(i + i);
        cout << "\\";
        //include space
        this->space(row - i - 1);
      }
      //include new line

      cout << "\n";
    }
    //Display bottom half result

    for (int i = 0; i < row; ++i) {
      for (int j = 0; j < column; ++j) {
        //Display result
        this->space(i);
        cout << "\\";
        //include space
        this->space((row - i - 1) *2);
        cout << "/";
        this->space(i);
      }
      //include new line

      cout << "\n";
    }
  }
};
int main() {
  MyPattern obj =  MyPattern();
  //Test Cases
  obj.wave_pattern(6, 3);
  obj.wave_pattern(3, 8);
  obj.wave_pattern(8, 3);
  return 0;
}

Output

Height : 6 Width : 3

  /\    /\    /\
 /  \  /  \  /  \
/    \/    \/    \
\    /\    /\    /
 \  /  \  /  \  /
  \/    \/    \/

The height is odd, to the height is increased by one
Height : 4 Width : 8

 /\  /\  /\  /\  /\  /\  /\  /\
/  \/  \/  \/  \/  \/  \/  \/  \
\  /\  /\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/  \/  \/

Height : 8 Width : 3

   /\      /\      /\
  /  \    /  \    /  \
 /    \  /    \  /    \
/      \/      \/      \
\      /\      /\      /
 \    /  \    /  \    /
  \  /    \  /    \  /
   \/      \/      \/
/*
  Java Program
  Display Wave Patterns
*/

public class MyPattern {
 

  //display space
  public void space(int size)
  {
    for (int i = 0; i < size; ++i)
    {
      System.out.print(" ");
    }
  }
  //Displaying of wave pattern in given size
  public void wave_pattern(int r,int column)
  {

    int row=(r/2);


    if(r<=0 || column<=0 )
    {
      //When get a invalid size
      return;
    }
    else if(r%2!=0)
    {
      System.out.print("\nThe height is odd, to the height is increased by one");
      System.out.print("\nHeight : "+(r+1)+"  Width : "+column+"\n\n" );
      row+=1;
    }
    else
    {
       System.out.print("\nHeight : "+r+"  Width : "+column+"\n\n" );
    }
   
    
    //Display top half result
    for (int i = 0; i < row; ++i)
    {
      for (int j = 0; j < column  ; ++j)
      {
        //Display result
        space(row-i-1);

        System.out.print("/");
        //include space
        space(i+i);
        System.out.print("\\");
        //include space
        space(row-i-1);

      }
      //include new line
      System.out.print("\n");


    }
    //Display bottom half result
    for (int i = 0; i < row; ++i)
    {
      for (int j = 0; j < column  ; ++j)
      {
        //Display result
        space(i);

        System.out.print("\\");
        //include space
        space((row-i-1)*2);
        System.out.print("/");
        space(i);

      }
      //include new line
      System.out.print("\n");
    }
   
  }
  public static void main(String[] args) {

    MyPattern obj = new MyPattern();

    //Test Cases
    obj.wave_pattern(6,3);
    obj.wave_pattern(3,8);
    obj.wave_pattern(8,3);
  }
}

Output

Height : 6 Width : 3

  /\    /\    /\
 /  \  /  \  /  \
/    \/    \/    \
\    /\    /\    /
 \  /  \  /  \  /
  \/    \/    \/

The height is odd, to the height is increased by one
Height : 4 Width : 8

 /\  /\  /\  /\  /\  /\  /\  /\
/  \/  \/  \/  \/  \/  \/  \/  \
\  /\  /\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/  \/  \/

Height : 8 Width : 3

   /\      /\      /\
  /  \    /  \    /  \
 /    \  /    \  /    \
/      \/      \/      \
\      /\      /\      /
 \    /  \    /  \    /
  \  /    \  /    \  /
   \/      \/      \/
/*
  C# Program
  Display Wave Patterns
*/
using System;

public class MyPattern {
  //display space
  public void space(int size) {
    for (int i = 0; i < size; ++i) {
      Console.Write(" ");
    }
  }
  //Displaying of wave pattern in given size
  public void wave_pattern(int r, int column) {
    int row = (r / 2);
    if (r <= 0 || column <= 0) {
      return;
    } else
    if (r % 2 != 0) {
      Console.Write("\nThe height is odd, to the height is increased by one");
      Console.Write("\nHeight : " + (r + 1) + " Width : " + column + "\n\n");
      row += 1;
    } else {
      Console.Write("\nHeight : " + r + " Width : " + column + "\n\n");
    }
    //Display top half result

    for (int i = 0; i < row; ++i) {
      for (int j = 0; j < column; ++j) {
        space(row - i - 1);
        Console.Write("/");
        space(i + i);
        Console.Write("\\");
        space(row - i - 1);
      }
      Console.Write("\n");
    }
    //Display bottom half result

    for (int i = 0; i < row; ++i) {
      for (int j = 0; j < column; ++j) {
        space(i);
        Console.Write("\\");
        space((row - i - 1) * 2);
        Console.Write("/");
        space(i);
      }
      Console.Write("\n");
    }
  }
  public static void Main(String[] args) {
    MyPattern obj = new MyPattern();
    obj.wave_pattern(6, 3);
    obj.wave_pattern(3, 8);
    obj.wave_pattern(8, 3);
  }
}

Output

Height : 6 Width : 3

  /\    /\    /\
 /  \  /  \  /  \
/    \/    \/    \
\    /\    /\    /
 \  /  \  /  \  /
  \/    \/    \/

The height is odd, to the height is increased by one
Height : 4 Width : 8

 /\  /\  /\  /\  /\  /\  /\  /\
/  \/  \/  \/  \/  \/  \/  \/  \
\  /\  /\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/  \/  \/

Height : 8 Width : 3

   /\      /\      /\
  /  \    /  \    /  \
 /    \  /    \  /    \
/      \/      \/      \
\      /\      /\      /
 \    /  \    /  \    /
  \  /    \  /    \  /
   \/      \/      \/
<?php
/*
  Php Program
  Display Wave Patterns
*/
class MyPattern {
  //display space
  public  function space($size) {
    for ($i = 0; $i < $size; ++$i) {
      echo(" ");
    }
  }
  //Displaying of wave pattern in given size
  public  function wave_pattern($r, $column) {
    $row = (intval($r / 2));
    if ($r <= 0 || $column <= 0) {
      return;
    } else
    if ($r % 2 != 0) {
      echo("\nThe height is odd, to the height is increased by one");
      echo("\nHeight : ". ($r + 1) ." Width : ". $column ."\n\n");
      $row += 1;
    } else {
      echo("\nHeight : ". $r ." Width : ". $column ."\n\n");
    }
    //Display top half result
    for ($i = 0; $i < $row; ++$i) {
      for ($j = 0; $j < $column; ++$j) {
        //Display result
        $this->space($row - $i - 1);
        echo("/");
        //include space
        $this->space($i + $i);
        echo("\\");
        //include space
        $this->space($row - $i - 1);
      }
      //include new line
      echo("\n");
    }
    //Display bottom half result

    for ($i = 0; $i < $row; ++$i) {
      for ($j = 0; $j < $column; ++$j) {
        //Display result
        $this->space($i);
        echo("\\");
        //include space
        $this->space(($row - $i - 1) *2);
        echo("/");
        $this->space($i);
      }
      //include new line
      echo("\n");
    }
  }
}

function main() {
  $obj = new MyPattern();
  //Test Cases
  $obj->wave_pattern(6, 3);
  $obj->wave_pattern(3, 8);
  $obj->wave_pattern(8, 3);

}
main();

Output

Height : 6 Width : 3

  /\    /\    /\
 /  \  /  \  /  \
/    \/    \/    \
\    /\    /\    /
 \  /  \  /  \  /
  \/    \/    \/

The height is odd, to the height is increased by one
Height : 4 Width : 8

 /\  /\  /\  /\  /\  /\  /\  /\
/  \/  \/  \/  \/  \/  \/  \/  \
\  /\  /\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/  \/  \/

Height : 8 Width : 3

   /\      /\      /\
  /  \    /  \    /  \
 /    \  /    \  /    \
/      \/      \/      \
\      /\      /\      /
 \    /  \    /  \    /
  \  /    \  /    \  /
   \/      \/      \/
/*
  Node Js Program
  Display Wave Patterns
*/
class MyPattern {
  //display space
  space(size) {
    for (var i = 0; i < size; ++i) {
      process.stdout.write(" ");
    }
  }

  //Displaying of wave pattern in given size
  wave_pattern(r, column) {
    var row = (parseInt(r / 2));
    if (r <= 0 || column <= 0) {
      return;
    } else
    if (r % 2 != 0) {
      process.stdout.write("\nThe height is odd, to the height is increased by one");
      process.stdout.write("\nHeight : " + (r + 1) + " Width : " + column + "\n\n");
      row += 1;
    } else {
      process.stdout.write("\nHeight : " + r + " Width : " + column + "\n\n");
    }

    //Display top half result

    for (var i = 0; i < row; ++i) {
      for (var j = 0; j < column; ++j) {
        //Display result
        this.space(row - i - 1);
        process.stdout.write("/");
        //include space
        this.space(i + i);
        process.stdout.write("\\");
        //include space
        this.space(row - i - 1);
      }

      //include new line

      process.stdout.write("\n");
    }

    //Display bottom half result

    for (var i = 0; i < row; ++i) {
      for (var j = 0; j < column; ++j) {
        //Display result
        this.space(i);
        process.stdout.write("\\");
        //include space
        this.space((row - i - 1) *2);
        process.stdout.write("/");
        this.space(i);
      }

      //include new line

      process.stdout.write("\n");
    }
  }
}

function main(args) {
  var obj = new MyPattern();
  //Test Cases
  obj.wave_pattern(6, 3);
  obj.wave_pattern(3, 8);
  obj.wave_pattern(8, 3);
}

main();

Output

Height : 6 Width : 3

  /\    /\    /\
 /  \  /  \  /  \
/    \/    \/    \
\    /\    /\    /
 \  /  \  /  \  /
  \/    \/    \/

The height is odd, to the height is increased by one
Height : 4 Width : 8

 /\  /\  /\  /\  /\  /\  /\  /\
/  \/  \/  \/  \/  \/  \/  \/  \
\  /\  /\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/  \/  \/

Height : 8 Width : 3

   /\      /\      /\
  /  \    /  \    /  \
 /    \  /    \  /    \
/      \/      \/      \
\      /\      /\      /
 \    /  \    /  \    /
  \  /    \  /    \  /
   \/      \/      \/
#   Python 3 Program
#   Display Wave Patterns

class MyPattern :
  # display space
  def space(self, size) :
    i = 0
    while (i < size) :
      print(" ", end = "")
      i += 1
    
  
  # Displaying of wave pattern in given size
  def wave_pattern(self, r, column) :
    row = (int(r / 2))
    if (r <= 0 or column <= 0) :
      return
    elif (r % 2 != 0) :
      print("\nThe height is odd, to the height is increased by one", end = "")
      print("\nHeight : ", (r + 1) ," Width : ", column ,"\n\n", end = "")
      row += 1
    else :
      print("\nHeight : ", r ," Width : ", column ,"\n\n", end = "")
    
    # Display top half result
    i = 0
    j = 0
    while (i < row) :
      j = 0
      while (j < column) :
        self.space(row - i - 1)
        print("/", end = "")
        self.space(i + i)
        print("\\", end = "")
        self.space(row - i - 1)
        j += 1
      
      print("\n", end = "")
      i += 1
    
    # Display bottom half result
    i = 0
    while (i < row) :
      j = 0
      while (j < column) :
        self.space(i)
        print("\\", end = "")
        self.space((row - i - 1) * 2)
        print("/", end = "")
        self.space(i)
        j += 1
      
      print("\n", end = "")
      i += 1
    
  

def main() :
  obj = MyPattern()
  obj.wave_pattern(6, 3)
  obj.wave_pattern(3, 8)
  obj.wave_pattern(8, 3)


if __name__ == "__main__":
  main()

Output

Height :  6  Width :  3

  /\    /\    /\
 /  \  /  \  /  \
/    \/    \/    \
\    /\    /\    /
 \  /  \  /  \  /
  \/    \/    \/

The height is odd, to the height is increased by one
Height :  4  Width :  8

 /\  /\  /\  /\  /\  /\  /\  /\
/  \/  \/  \/  \/  \/  \/  \/  \
\  /\  /\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/  \/  \/

Height :  8  Width :  3

   /\      /\      /\
  /  \    /  \    /  \
 /    \  /    \  /    \
/      \/      \/      \
\      /\      /\      /
 \    /  \    /  \    /
  \  /    \  /    \  /
   \/      \/      \/
#   Ruby Program
#   Display Wave Patterns

class MyPattern 
   # display space
  def space(size) 
    i = 0
    while (i < size) 
      print(" ")
      i += 1
    end
  end
   # Displaying of wave pattern in given size
  def wave_pattern(r, column) 
    row = (r / 2)
    if (r <= 0 || column <= 0) 
      return
    elsif (r % 2 != 0) 
      print("\nThe height is odd, to the height is increased by one")
      print("\nHeight  :", (r + 1) ," Width  :", column ,"\n\n")
      row += 1
    else 
      print("\nHeight  :", r ," Width  :", column ,"\n\n")
    end
     # Display top half result
    i = 0
    j = 0
    while (i < row) 
      j = 0
      while (j < column) 
        self.space(row - i - 1)
        print("/")
        self.space(i + i)
        print("\\")
        self.space(row - i - 1)
        j += 1
      end
      print("\n")
      i += 1
    end
     # Display bottom half result
    i = 0
    while (i < row) 
      j = 0
      while (j < column) 
        self.space(i)
        print("\\")
        self.space((row - i - 1) * 2)
        print("/")
        self.space(i)
        j += 1
      end
      print("\n")
      i += 1
    end
  end
end
def main() 
  obj = MyPattern.new()
  obj.wave_pattern(6, 3)
  obj.wave_pattern(3, 8)
  obj.wave_pattern(8, 3)
end
main()

Output

Height  :6 Width  :3

  /\    /\    /\  
 /  \  /  \  /  \ 
/    \/    \/    \
\    /\    /\    /
 \  /  \  /  \  / 
  \/    \/    \/  

The height is odd, to the height is increased by one
Height  :4 Width  :8

 /\  /\  /\  /\  /\  /\  /\  /\ 
/  \/  \/  \/  \/  \/  \/  \/  \
\  /\  /\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/  \/  \/ 

Height  :8 Width  :3

   /\      /\      /\   
  /  \    /  \    /  \  
 /    \  /    \  /    \ 
/      \/      \/      \
\      /\      /\      /
 \    /  \    /  \    / 
  \  /    \  /    \  /  
   \/      \/      \/   
/*
  Scala Program
  Display Wave Patterns
*/
class MyPattern {
  //display space
  def space(size: Int): Unit = {
    var i: Int = 0;
    while (i < size) {
      print(" ");
      i += 1;
    }
  }
  //Displaying of wave pattern in given size
  def wave_pattern(r: Int, column: Int): Unit = {
    var row: Int = ((r / 2).toInt);

    if (r <= 0 || column <= 0) {
      return;
    } else
    if (r % 2 != 0) {
      print("\nThe height is odd, to the height is increased by one");
      print("\nHeight : " + (r + 1) + " Width : " + column + "\n\n");
      row += 1;
    } else {
      print("\nHeight : " + r + " Width : " + column + "\n\n");
    }
    //Display top half result
    var i: Int = 0;
    var j: Int = 0;
    while (i < row) {
      j = 0;
      while (j < column) {
        this.space(row - i - 1);
        print("/");
        this.space(i + i);
        print("\\");
        this.space(row - i - 1);
        j += 1;
      }
      print("\n");
      i += 1;
    }
    //Display bottom half result
    i = 0;
    while (i < row) {
      j = 0;
      while (j < column) {
        this.space(i);
        print("\\");
        this.space((row - i - 1) * 2);
        print("/");
        this.space(i);
        j += 1;
      }
      print("\n");
      i += 1;
    }
  }
}
object Main {
  def main(args: Array[String]): Unit = {
    val obj: MyPattern = new MyPattern();
    obj.wave_pattern(6, 3);
    obj.wave_pattern(3, 8);
    obj.wave_pattern(8, 3);
  }
}

Output

Height : 6 Width : 3

  /\    /\    /\
 /  \  /  \  /  \
/    \/    \/    \
\    /\    /\    /
 \  /  \  /  \  /
  \/    \/    \/

The height is odd, to the height is increased by one
Height : 4 Width : 8

 /\  /\  /\  /\  /\  /\  /\  /\
/  \/  \/  \/  \/  \/  \/  \/  \
\  /\  /\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/  \/  \/

Height : 8 Width : 3

   /\      /\      /\
  /  \    /  \    /  \
 /    \  /    \  /    \
/      \/      \/      \
\      /\      /\      /
 \    /  \    /  \    /
  \  /    \  /    \  /
   \/      \/      \/
/*
  Swift Program
  Display Wave Patterns
*/
class MyPattern {
  //display space
  func space(_ size: Int) {
    var i = 0;
    while (i < size) {
      print(" ", terminator: "");
      i += 1;
    }
  }
  //Displaying of wave pattern in given size
  func wave_pattern(_ r: Int, _ column: Int) {
    var row = (r / 2);
    if (r <= 0 || column <= 0) {
      return;
    } else
    if (r % 2 != 0) {
      print("\nThe height is odd, to the height is increased by one", terminator: "");
      print("\nHeight : ", (r + 1) ," Width : ", column ,"\n\n", terminator: "");
      row += 1;
    } else {
      print("\nHeight : ", r ," Width : ", column ,"\n\n", terminator: "");
    }
    //Display top half result
    var i = 0;
    var j = 0;
    while (i < row) {
      j = 0;
      while (j < column) {
        self.space(row - i - 1);
        print("/", terminator: "");
        self.space(i + i);
        print("\\", terminator: "");
        self.space(row - i - 1);
        j += 1;
      }
      print("\n", terminator: "");
      i += 1;
    }
    //Display bottom half result
    i = 0;
    while (i < row) {
      j = 0;
      while (j < column) {
        self.space(i);
        print("\\", terminator: "");
        self.space((row - i - 1) * 2);
        print("/", terminator: "");
        self.space(i);
        j += 1;
      }
      print("\n", terminator: "");
      i += 1;
    }
  }
}
func main() {
  let obj = MyPattern();
  obj.wave_pattern(6, 3);
  obj.wave_pattern(3, 8);
  obj.wave_pattern(8, 3);
}
main();

Output

Height :  6  Width :  3

  /\    /\    /\
 /  \  /  \  /  \
/    \/    \/    \
\    /\    /\    /
 \  /  \  /  \  /
  \/    \/    \/

The height is odd, to the height is increased by one
Height :  4  Width :  8

 /\  /\  /\  /\  /\  /\  /\  /\
/  \/  \/  \/  \/  \/  \/  \/  \
\  /\  /\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/  \/  \/

Height :  8  Width :  3

   /\      /\      /\
  /  \    /  \    /  \
 /    \  /    \  /    \
/      \/      \/      \
\      /\      /\      /
 \    /  \    /  \    /
  \  /    \  /    \  /
   \/      \/      \/
//C Program 
//Display Wave Patterns
#include <stdio.h>

#include <stdlib.h>

//display space
void space(int size)
{
  for (int i = 0; i < size; ++i)
  {
    printf(" ");
  }
}
//Displaying of wave pattern in given size
void wave_pattern(int r,int column)
{

  int row=(r/2);


  if(r<=0 || column<=0 )
  {
    //When get a invalid size
    return;
  }
  else if(r%2!=0)
  {
    printf("\nThe height is odd, to the height is increased by one");
    printf("\nHeight : %d  Width : %d\n\n",r+1,column );
    row+=1;
  }
  else
  {
     printf("\nHeight : %d  Width : %d\n\n",r,column );
  }
  for (int i = 0; i < row; ++i)
  {
    for (int j = 0; j < column  ; ++j)
    {
      //Display result
      space(i);

      printf("\\");
      //include space
      space((row-i-1)*2);
      printf("/");
      space(i);

    }
    //include new line
    printf("\n");
  }

  for (int i = 0; i < row; ++i)
  {
    for (int j = 0; j < column  ; ++j)
    {
      //Display result
      space(row-i-1);

      printf("/");
      //include space
      space(i+i);
      printf("\\");
      space(row-i-1);

    }
    //include new line
    printf("\n");


  }
}
int main() {
    //Test Cases
    wave_pattern(6,3);
    wave_pattern(3,6);
    wave_pattern(8,3);
   
 return 0;
}

Output

Height : 6  Width : 3

\    /\    /\    /
 \  /  \  /  \  /
  \/    \/    \/
  /\    /\    /\
 /  \  /  \  /  \
/    \/    \/    \

The height is odd, to the height is increased by one
Height : 4  Width : 6

\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/
 /\  /\  /\  /\  /\  /\
/  \/  \/  \/  \/  \/  \

Height : 8  Width : 3

\      /\      /\      /
 \    /  \    /  \    /
  \  /    \  /    \  /
   \/      \/      \/
   /\      /\      /\
  /  \    /  \    /  \
 /    \  /    \  /    \
/      \/      \/      \
/*
  C++ Program
  Display Wave Patterns
*/
#include<iostream>

using namespace std;
class MyPattern {
  public:

    //display space
    void space(int size) {
      for (int i = 0; i < size; ++i) {
        cout << " ";
      }
    }
  //Displaying of wave pattern in given size
  void wave_pattern(int r, int column) {
    int row = (r / 2);
    if (r <= 0 || column <= 0) {
      //When get a invalid size

      return;
    } else
    if (r % 2 != 0) {
      cout << "\nThe height is odd, to the height is increased by one";
      cout << "\nHeight : " << (r + 1) << " Width : " << column << "\n\n";
      row += 1;
    } else {
      cout << "\nHeight : " << r << " Width : " << column << "\n\n";
    }
    for (int i = 0; i < row; ++i) {
      for (int j = 0; j < column; ++j) {
        //Display result
        this->space(i);
        cout << "\\";
        //include space
        this->space((row - i - 1) *2);
        cout << "/";
        this->space(i);
      }
      //include new line

      cout << "\n";
    }
    for (int i = 0; i < row; ++i) {
      for (int j = 0; j < column; ++j) {
        //Display result
        this->space(row - i - 1);
        cout << "/";
        //include space
        this->space(i + i);
        cout << "\\";
        //include space
        this->space(row - i - 1);
      }
      //include new line

      cout << "\n";
    }
  }
};
int main() {
  MyPattern obj =  MyPattern();
  //Test Cases
  obj.wave_pattern(6, 3);
  obj.wave_pattern(3, 6);
  obj.wave_pattern(8, 3);
  return 0;
}

Output

Height : 6 Width : 3

\    /\    /\    /
 \  /  \  /  \  /
  \/    \/    \/
  /\    /\    /\
 /  \  /  \  /  \
/    \/    \/    \

The height is odd, to the height is increased by one
Height : 4 Width : 6

\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/
 /\  /\  /\  /\  /\  /\
/  \/  \/  \/  \/  \/  \

Height : 8 Width : 3

\      /\      /\      /
 \    /  \    /  \    /
  \  /    \  /    \  /
   \/      \/      \/
   /\      /\      /\
  /  \    /  \    /  \
 /    \  /    \  /    \
/      \/      \/      \
/*
  Java Program
  Display Wave Patterns
*/

public class MyPattern {
 

  //display space
  public void space(int size)
  {
    for (int i = 0; i < size; ++i)
    {
      System.out.print(" ");
    }
  }
  //Displaying of wave pattern in given size
  public void wave_pattern(int r,int column)
  {

    int row=(r/2);


    if(r<=0 || column<=0 )
    {
      //When get a invalid size
      return;
    }
    else if(r%2!=0)
    {
      System.out.print("\nThe height is odd, to the height is increased by one");
      System.out.print("\nHeight : "+(r+1)+"  Width : "+column+"\n\n" );
      row+=1;
    }
    else
    {
       System.out.print("\nHeight : "+r+"  Width : "+column+"\n\n" );
    }
   
    for (int i = 0; i < row; ++i)
    {
      for (int j = 0; j < column  ; ++j)
      {
        //Display result
        space(i);

        System.out.print("\\");
        //include space
        space((row-i-1)*2);
        System.out.print("/");
        space(i);

      }
      //include new line
      System.out.print("\n");
    }

    for (int i = 0; i < row; ++i)
    {
      for (int j = 0; j < column  ; ++j)
      {
        //Display result
        space(row-i-1);

        System.out.print("/");
        //include space
        space(i+i);
        System.out.print("\\");
        //include space
        space(row-i-1);

      }
      //include new line
      System.out.print("\n");


    }


   
  }
  public static void main(String[] args) {

    MyPattern obj = new MyPattern();

    //Test Cases
    obj.wave_pattern(6,3);
    obj.wave_pattern(3,6);
    obj.wave_pattern(8,3);
  }
}

Output

Height : 6 Width : 3

\    /\    /\    /
 \  /  \  /  \  /
  \/    \/    \/
  /\    /\    /\
 /  \  /  \  /  \
/    \/    \/    \

The height is odd, to the height is increased by one
Height : 4 Width : 6

\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/
 /\  /\  /\  /\  /\  /\
/  \/  \/  \/  \/  \/  \

Height : 8 Width : 3

\      /\      /\      /
 \    /  \    /  \    /
  \  /    \  /    \  /
   \/      \/      \/
   /\      /\      /\
  /  \    /  \    /  \
 /    \  /    \  /    \
/      \/      \/      \
/*
  C# Program
  Display Wave Patterns
*/
using System;

public class MyPattern {
  //display space
  public void space(int size) {
    for (int i = 0; i < size; ++i) {
      Console.Write(" ");
    }
  }
  //Displaying of wave pattern in given size
  public void wave_pattern(int r, int column) {
    int row = (r / 2);
    if (r <= 0 || column <= 0) {
      return;
    } else
    if (r % 2 != 0) {
      Console.Write("\nThe height is odd, to the height is increased by one");
      Console.Write("\nHeight : " + (r + 1) + " Width : " + column + "\n\n");
      row += 1;
    } else {
      Console.Write("\nHeight : " + r + " Width : " + column + "\n\n");
    }
    for (int i = 0; i < row; ++i) {
      for (int j = 0; j < column; ++j) {
        space(i);
        Console.Write("\\");
        space((row - i - 1) * 2);
        Console.Write("/");
        space(i);
      }
      Console.Write("\n");
    }
    for (int i = 0; i < row; ++i) {
      for (int j = 0; j < column; ++j) {
        space(row - i - 1);
        Console.Write("/");
        space(i + i);
        Console.Write("\\");
        space(row - i - 1);
      }
      Console.Write("\n");
    }
  }
  public static void Main(String[] args) {
    MyPattern obj = new MyPattern();
    obj.wave_pattern(6, 3);
    obj.wave_pattern(3, 6);
    obj.wave_pattern(8, 3);
  }
}

Output

Height : 6 Width : 3

\    /\    /\    /
 \  /  \  /  \  /
  \/    \/    \/
  /\    /\    /\
 /  \  /  \  /  \
/    \/    \/    \

The height is odd, to the height is increased by one
Height : 4 Width : 6

\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/
 /\  /\  /\  /\  /\  /\
/  \/  \/  \/  \/  \/  \

Height : 8 Width : 3

\      /\      /\      /
 \    /  \    /  \    /
  \  /    \  /    \  /
   \/      \/      \/
   /\      /\      /\
  /  \    /  \    /  \
 /    \  /    \  /    \
/      \/      \/      \
<?php
/*
  Php Program
  Display Wave Patterns
*/
class MyPattern {
  //display space

  public  function space($size) {
    for ($i = 0; $i < $size; ++$i) {
      echo(" ");
    }
  }
  //Displaying of wave pattern in given size

  public  function wave_pattern($r, $column) {
    $row = (intval($r / 2));
    if ($r <= 0 || $column <= 0) {
      return;
    } else
    if ($r % 2 != 0) {
      echo("\nThe height is odd, to the height is increased by one");
      echo("\nHeight : ". ($r + 1) ." Width : ". $column ."\n\n");
      $row += 1;
    } else {
      echo("\nHeight : ". $r ." Width : ". $column ."\n\n");
    }
    for ($i = 0; $i < $row; ++$i) {
      for ($j = 0; $j < $column; ++$j) {
        //Display result
        $this->space($i);
        echo("\\");
        //include space
        $this->space(($row - $i - 1) *2);
        echo("/");
        $this->space($i);
      }
      //include new line

      echo("\n");
    }
    for ($i = 0; $i < $row; ++$i) {
      for ($j = 0; $j < $column; ++$j) {
        //Display result
        $this->space($row - $i - 1);
        echo("/");
        //include space
        $this->space($i + $i);
        echo("\\");
        //include space
        $this->space($row - $i - 1);
      }
      //include new line

      echo("\n");
    }
  }
}

function main() {
  $obj = new MyPattern();
  //Test Cases

  $obj->wave_pattern(6, 3);
  $obj->wave_pattern(3, 6);
  $obj->wave_pattern(8, 3);

}
main();

Output

Height : 6 Width : 3

\    /\    /\    /
 \  /  \  /  \  /
  \/    \/    \/
  /\    /\    /\
 /  \  /  \  /  \
/    \/    \/    \

The height is odd, to the height is increased by one
Height : 4 Width : 6

\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/
 /\  /\  /\  /\  /\  /\
/  \/  \/  \/  \/  \/  \

Height : 8 Width : 3

\      /\      /\      /
 \    /  \    /  \    /
  \  /    \  /    \  /
   \/      \/      \/
   /\      /\      /\
  /  \    /  \    /  \
 /    \  /    \  /    \
/      \/      \/      \
/*
  Node Js Program
  Display Wave Patterns
*/
class MyPattern {
  //display space
  space(size) {
    for (var i = 0; i < size; ++i) {
      process.stdout.write(" ");
    }
  }

  //Displaying of wave pattern in given size
  wave_pattern(r, column) {
    var row = (parseInt(r / 2));
    if (r <= 0 || column <= 0) {
      return;
    } else
    if (r % 2 != 0) {
      process.stdout.write("\nThe height is odd, to the height is increased by one");
      process.stdout.write("\nHeight : " + (r + 1) + " Width : " + column + "\n\n");
      row += 1;
    } else {
      process.stdout.write("\nHeight : " + r + " Width : " + column + "\n\n");
    }

    for (var i = 0; i < row; ++i) {
      for (var j = 0; j < column; ++j) {
        //Display result
        this.space(i);
        process.stdout.write("\\");
        //include space
        this.space((row - i - 1) *2);
        process.stdout.write("/");
        this.space(i);
      }

      //include new line

      process.stdout.write("\n");
    }

    for (var i = 0; i < row; ++i) {
      for (var j = 0; j < column; ++j) {
        //Display result
        this.space(row - i - 1);
        process.stdout.write("/");
        //include space
        this.space(i + i);
        process.stdout.write("\\");
        //include space
        this.space(row - i - 1);
      }

      //include new line

      process.stdout.write("\n");
    }
  }
}

function main(args) {
  var obj = new MyPattern();
  //Test Cases
  obj.wave_pattern(6, 3);
  obj.wave_pattern(3, 6);
  obj.wave_pattern(8, 3);
}

main();

Output

Height : 6 Width : 3

\    /\    /\    /
 \  /  \  /  \  /
  \/    \/    \/
  /\    /\    /\
 /  \  /  \  /  \
/    \/    \/    \

The height is odd, to the height is increased by one
Height : 4 Width : 6

\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/
 /\  /\  /\  /\  /\  /\
/  \/  \/  \/  \/  \/  \

Height : 8 Width : 3

\      /\      /\      /
 \    /  \    /  \    /
  \  /    \  /    \  /
   \/      \/      \/
   /\      /\      /\
  /  \    /  \    /  \
 /    \  /    \  /    \
/      \/      \/      \
#   Python 3 Program
#   Display Wave Patterns

class MyPattern :
  # display space
  def space(self, size) :
    i = 0
    while (i < size) :
      print(" ", end = "")
      i += 1
    
  
  # Displaying of wave pattern in given size
  def wave_pattern(self, r, column) :
    row = (int(r / 2))
    if (r <= 0 or column <= 0) :
      return
    elif (r % 2 != 0) :
      print("\nThe height is odd, to the height is increased by one", end = "")
      print("\nHeight : ", (r + 1) ," Width : ", column ,"\n\n", end = "")
      row += 1
    else :
      print("\nHeight : ", r ," Width : ", column ,"\n\n", end = "")
    
    i = 0
    while (i < row) :
      j = 0
      while (j < column) :
        self.space(i)
        print("\\", end = "")
        self.space((row - i - 1) * 2)
        print("/", end = "")
        self.space(i)
        j += 1
      
      print("\n", end = "")
      i += 1
    
    i = 0
    while (i < row) :
      j = 0
      while (j < column) :
        self.space(row - i - 1)
        print("/", end = "")
        self.space(i + i)
        print("\\", end = "")
        self.space(row - i - 1)
        j += 1
      
      print("\n", end = "")
      i += 1
    
  

def main() :
  obj = MyPattern()
  obj.wave_pattern(6, 3)
  obj.wave_pattern(3, 6)
  obj.wave_pattern(8, 3)


if __name__ == "__main__":
  main()

Output

Height :  6  Width :  3

\    /\    /\    /
 \  /  \  /  \  /
  \/    \/    \/
  /\    /\    /\
 /  \  /  \  /  \
/    \/    \/    \

The height is odd, to the height is increased by one
Height :  4  Width :  6

\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/
 /\  /\  /\  /\  /\  /\
/  \/  \/  \/  \/  \/  \

Height :  8  Width :  3

\      /\      /\      /
 \    /  \    /  \    /
  \  /    \  /    \  /
   \/      \/      \/
   /\      /\      /\
  /  \    /  \    /  \
 /    \  /    \  /    \
/      \/      \/      \
#   Ruby Program
#   Display Wave Patterns

class MyPattern 
   # display space
  def space(size) 
    i = 0
    while (i < size) 
      print(" ")
      i += 1
    end
  end
   # Displaying of wave pattern in given size
  def wave_pattern(r, column) 
    row = (r / 2)
    if (r <= 0 || column <= 0) 
      return
    elsif (r % 2 != 0) 
      print("\nThe height is odd, to the height is increased by one")
      print("\nHeight  :", (r + 1) ," Width  :", column ,"\n\n")
      row += 1
    else 
      print("\nHeight  :", r ," Width  :", column ,"\n\n")
    end
    i = 0
    while (i < row) 
      j = 0
      while (j < column) 
        self.space(i)
        print("\\")
        self.space((row - i - 1) * 2)
        print("/")
        self.space(i)
        j += 1
      end
      print("\n")
      i += 1
    end
    i = 0
    while (i < row) 
      j = 0
      while (j < column) 
        self.space(row - i - 1)
        print("/")
        self.space(i + i)
        print("\\")
        self.space(row - i - 1)
        j += 1
      end
      print("\n")
      i += 1
    end
  end
end
def main() 
  obj = MyPattern.new()
  obj.wave_pattern(6, 3)
  obj.wave_pattern(3, 6)
  obj.wave_pattern(8, 3)
end
main()

Output

Height  :6 Width  :3

\    /\    /\    /
 \  /  \  /  \  / 
  \/    \/    \/  
  /\    /\    /\  
 /  \  /  \  /  \ 
/    \/    \/    \

The height is odd, to the height is increased by one
Height  :4 Width  :6

\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/ 
 /\  /\  /\  /\  /\  /\ 
/  \/  \/  \/  \/  \/  \

Height  :8 Width  :3

\      /\      /\      /
 \    /  \    /  \    / 
  \  /    \  /    \  /  
   \/      \/      \/   
   /\      /\      /\   
  /  \    /  \    /  \  
 /    \  /    \  /    \ 
/      \/      \/      \
/*
  Scala Program
  Display Wave Patterns
*/
class MyPattern {
  //display space
  def space(size: Int): Unit = {
    var i: Int = 0;
    while (i < size) {
      print(" ");
      i += 1;
    }
  }
  //Displaying of wave pattern in given size
  def wave_pattern(r: Int, column: Int): Unit = {
    var row: Int = ((r / 2).toInt);

    if (r <= 0 || column <= 0) {
      return;
    } else
    if (r % 2 != 0) {
      print("\nThe height is odd, to the height is increased by one");
      print("\nHeight : " + (r + 1) + " Width : " + column + "\n\n");
      row += 1;
    } else {
      print("\nHeight : " + r + " Width : " + column + "\n\n");
    }
    var i: Int = 0;
    var j: Int = 0;
    while (i < row) {
      j = 0;
      while (j < column) {
        this.space(i);
        print("\\");
        this.space((row - i - 1) * 2);
        print("/");
        this.space(i);
        j += 1;
      }
      print("\n");
      i += 1;
    }
    i = 0;
    while (i < row) {
      j = 0;
      while (j < column) {
        this.space(row - i - 1);
        print("/");
        this.space(i + i);
        print("\\");
        this.space(row - i - 1);
        j += 1;
      }
      print("\n");
      i += 1;
    }
  }
}
object Main {
  def main(args: Array[String]): Unit = {
    val obj: MyPattern = new MyPattern();
    obj.wave_pattern(6, 3);
    obj.wave_pattern(3, 6);
    obj.wave_pattern(8, 3);
  }
}

Output

Height : 6 Width : 3

\    /\    /\    /
 \  /  \  /  \  /
  \/    \/    \/
  /\    /\    /\
 /  \  /  \  /  \
/    \/    \/    \

The height is odd, to the height is increased by one
Height : 4 Width : 6

\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/
 /\  /\  /\  /\  /\  /\
/  \/  \/  \/  \/  \/  \

Height : 8 Width : 3

\      /\      /\      /
 \    /  \    /  \    /
  \  /    \  /    \  /
   \/      \/      \/
   /\      /\      /\
  /  \    /  \    /  \
 /    \  /    \  /    \
/      \/      \/      \
/*
  Swift Program
  Display Wave Patterns
*/
class MyPattern {
  //display space
  func space(_ size: Int) {
    var i = 0;
    while (i < size) {
      print(" ", terminator: "");
      i += 1;
    }
  }
  //Displaying of wave pattern in given size
  func wave_pattern(_ r: Int, _ column: Int) {
    var row = (r / 2);
    if (r <= 0 || column <= 0) {
      return;
    } else
    if (r % 2 != 0) {
      print("\nThe height is odd, to the height is increased by one", terminator: "");
      print("\nHeight : ", (r + 1) ," Width : ", column ,"\n\n", terminator: "");
      row += 1;
    } else {
      print("\nHeight : ", r ," Width : ", column ,"\n\n", terminator: "");
    }
    var i = 0;
    var j = 0;
    while (i < row) {
      j = 0;
      while (j < column) {
        self.space(i);
        print("\\", terminator: "");
        self.space((row - i - 1) * 2);
        print("/", terminator: "");
        self.space(i);
        j += 1;
      }
      print("\n", terminator: "");
      i += 1;
    }
    i = 0;
    while (i < row) {
      j = 0;
      while (j < column) {
        self.space(row - i - 1);
        print("/", terminator: "");
        self.space(i + i);
        print("\\", terminator: "");
        self.space(row - i - 1);
        j += 1;
      }
      print("\n", terminator: "");
      i += 1;
    }
  }
}
func main() {
  let obj = MyPattern();
  obj.wave_pattern(6, 3);
  obj.wave_pattern(3, 6);
  obj.wave_pattern(8, 3);
}
main();

Output

Height :  6  Width :  3

\    /\    /\    /
 \  /  \  /  \  /
  \/    \/    \/
  /\    /\    /\
 /  \  /  \  /  \
/    \/    \/    \

The height is odd, to the height is increased by one
Height :  4  Width :  6

\  /\  /\  /\  /\  /\  /
 \/  \/  \/  \/  \/  \/
 /\  /\  /\  /\  /\  /\
/  \/  \/  \/  \/  \/  \

Height :  8  Width :  3

\      /\      /\      /
 \    /  \    /  \    /
  \  /    \  /    \  /
   \/      \/      \/
   /\      /\      /\
  /  \    /  \    /  \
 /    \  /    \  /    \
/      \/      \/      \




Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment