Give Height and Width of a Wave to print the pattern
Examples:
Input : wave_height=5
wave_length=10
Output :
>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>
>> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >>
>> >> >> >> >> >> >> >> >> >>
>> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >>
>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>
Recommended: Please try your approach on {IDE} first, before moving on to the solution.
Approach:
First, check the row and column where the elements are needed to be printed. Then, use nested for loops to print the elements in the corresponding order. Separate loops are kept to keep track of the wave_height and wave_length.
C++
// C program to print Mirror Image of sign wave pattern. #include <stdio.h> // Function to print Mirror Image of sign wave pattern void printWave(int wave_height, int wave_length) { // for loop for height of wave for (int i = 1; i <= wave_height; i++) { // for loop for wave length for (int j = 1; j <= wave_length; j++) { // intermediate spaces for (int k = 1; k <= wave_height; k++) { if (i == k || i + k == wave_height + 1) { // put any symbol printf(">>"); } else { printf(" "" "); } } } printf("\n"); } } // Driver code int main() { int wave_height = 5; int wave_length = 10; printWave(wave_height, wave_length); return 0; } |
chevron_right
filter_none
Java
// Java program to print Mirror // Image of sign wave pattern. class GFG { // Function to print Mirror // Image of sign wave pattern static void printWave(int wave_height, int wave_length) { // for loop for height of wave for (int i = 1; i <= wave_height; i++) { // for loop for wave length for (int j = 1; j <= wave_length; j++) { // intermediate spaces for (int k = 1; k <= wave_height; k++) { if (i == k || i + k == wave_height + 1) { // put any symbol System.out.printf(">>"); } else { System.out.printf(" " + " "); } } } System.out.printf("\n"); } } // Driver code public static void main(String[] args) { int wave_height = 5; int wave_length = 10; printWave(wave_height, wave_length); } } // This code is contributed // by Smitha |
chevron_right
filter_none
Python3
# Python3 program to prMirror # Image of sign wave pattern. # Function to prMirror Image # of sign wave pattern def printWave(wave_height, wave_length): # for loop for height of wave for i in range(1, wave_height + 1, 1): # for loop for wave length for j in range(1, wave_length + 1, 1): # intermediate spaces for k in range(1, wave_height + 1, 1): if (i == k or i + k == wave_height + 1): # put any symbol print(">>", end = ""); else: print(" ", end = " "); print(); # Driver code if __name__ == '__main__': wave_height = 5; wave_length = 10; printWave(wave_height, wave_length); # This code is contributed by PrinciRaj1992 |
chevron_right
filter_none
C#
// C# program to print Mirror // Image of sign wave pattern. using System; class GFG { // Function to print Mirror // Image of sign wave pattern static void printWave(int wave_height, int wave_length) { // for loop for height of wave for (int i = 1; i <= wave_height; i++) { // for loop for wave length for (int j = 1; j <= wave_length; j++) { // intermediate spaces for (int k = 1; k <= wave_height; k++) { if (i == k || i + k == wave_height + 1) { // put any symbol Console.Write(">>"); } else { Console.Write(" " + " "); } } } Console.Write("\n"); } } // Driver code public static void Main() { int wave_height = 5; int wave_length = 10; printWave(wave_height, wave_length); } } // This code is contributed // by Smitha |
chevron_right
filter_none
Output
>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>
>> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >>
>> >> >> >> >> >> >> >> >> >>
>> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >>
>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>
Recommended Posts:
- Program to print mirror image of Swastika Pattern
- Program for triangular pattern (mirror image around 0)
- Program to determine focal length of a spherical mirror
- Program to print a pattern of numbers
- Python Program to print digit pattern
- Program to print pyramid pattern
- Program to print hollow pyramid and diamond pattern
- C Program to print pyramid pattern
- Program to print a rectangle pattern
- Program to print interesting pattern
- Program to print number pattern
- Program to print number with star pattern
- Program to print reverse character bridge pattern
- Program to print numbers with diamond pattern
- Program to print a inverse pyramid character pattern
- Program to print the pattern 'G'
- Program to print the pattern ‘D’
- Program to print double headed arrow pattern
- Program to print V and inverted-V pattern
- Program to print the arrow pattern
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

