Program for Expressionless Face Pattern printing Last Updated : 20 Feb, 2023 Comments Improve Suggest changes Like Article Like Report Given the value of n, i.e, number of lines, print the pattern. Examples : Input: n = 5Output:*_*****_*****_***_****_****_*****_***_***_*******_**_**_*********_*_*_***** Input: n = 10Output:*_**********_**********_***_*********_*********_*****_********_********_*******_*******_*******_*********_******_******_***********_*****_*****_*************_****_****_***************_***_***_*****************_**_**_*******************_*_*_********** C++ // C++ implementation to print the pattern #include <bits/stdc++.h> using namespace std; // Function to print required // number of stars void print1(int i) { for (int j = 1; j <= i; j++) cout << "*"; } void print(int n) { for (int i = 1; i <= n; i++) { // function calling to print // the initial stars in each line print1(i); // printing underscore cout << "_"; // function calling to print // stars on right side of first half print1(n - i + 1); // printing underscore cout << "_"; // function calling to print // stars on left side of second half print1(n - i + 1); // printing underscore cout << "_"; // function calling to print // the ending stars print1(i); cout << endl; } } // Driver code int main() { // number of lines int n = 5; // function calling print(n); return 0; } Java // Java implementation to print the pattern import java.io.*; class GFG { // Function to print required // number of stars static void print1(int i) { for (int j = 1; j <= i; j++) System.out.print("*"); } static void print(int n) { for (int i = 1; i <= n; i++) { // function calling to print // the initial stars in each line print1(i); // printing underscore System.out.print("_"); // function calling to print // stars on right side of first half print1(n - i + 1); // printing underscore System.out.print("_"); // function calling to print // stars on left side of second half print1(n - i + 1); // printing underscore System.out.print("_"); // function calling to print // the ending stars print1(i); System.out.println(); } } // Driver code public static void main (String[] args) { // number of lines int n = 5; // function calling print(n); } } // This code is contributed by vt_m. Python3 # Python3 implementation # to print the pattern # Function to print # required number of stars def print1(i): for j in range(1, i + 1): print("*", end = "") def printPattern(n): for i in range(1, n + 1): # function calling to # print the initial # stars in each line print1(i) # printing underscore print("_", end = "") # function calling to # print stars on right # side of first half print1(n - i + 1) # printing underscore print("_", end = "") # function calling to # print stars on left # side of second half print1(n - i + 1) # printing underscore print("_", end = "") # function calling to print # the ending stars print1(i) print("") # Driver code # number of lines n = 5 # function calling printPattern(n) # This code is contributed # by Smitha C# // C# implementation to print the pattern using System; class GFG { // Function to print required // number of stars static void print1(int i) { for (int j = 1; j <= i; j++) Console.Write("*"); } static void print(int n) { for (int i = 1; i <= n; i++) { // function calling to print // the initial stars in each line print1(i); // printing underscore Console.Write("_"); // function calling to print // stars on right side of first half print1(n - i + 1); // printing underscore Console.Write("_"); // function calling to print // stars on left side of second half print1(n - i + 1); // printing underscore Console.Write("_"); // function calling to print // the ending stars print1(i); Console.WriteLine(); } } // Driver code public static void Main () { // number of lines int n = 5; // function calling print(n); } } // This code is contributed by vt_m. PHP <?php // PHP implementation for // expressionless face pattern function print1($i) { for ($j = 1; $j <= $i; $j++) echo "*"; } function printp($n) { for ($i = 1; $i <= $n; $i++) { // function calling to print // the initial stars in each line print1($i); // printing underscore echo "_"; // function calling to print // stars on right side of first half print1($n - $i + 1); // printing underscore echo "_"; // function calling to print // stars on left side of second half print1($n - $i + 1); // printing underscore echo "_"; // function calling to print // the ending stars print1($i); echo "\n"; } } // Driver code $n = 5; printp($n); // This code is contributed by Mithun Kumar ?> JavaScript <script> // javascript implementation to print the pattern // Function to print required // number of stars function print1(i) { for (var j = 1; j <= i; j++) document.write("*"); } function print(n) { for (var i = 1; i <= n; i++) { // function calling to print // the initial stars in each line print1(i); // printing underscore document.write("_"); // function calling to print // stars on right side of first half print1(n - i + 1); // printing underscore document.write("_"); // function calling to print // stars on left side of second half print1(n - i + 1); // printing underscore document.write("_"); // function calling to print // the ending stars print1(i); document.write('<br>'); } } // Driver code // number of lines var n = 5; // function calling print(n); // This code is contributed by 29AjayKumar </script> Time complexity: O(n2), where n is the given integer.Auxiliary space: O(1) using constant space for variables Comment More infoAdvertise with us Next Article Program for Expressionless Face Pattern printing B bansal_rtk_ Follow Improve Article Tags : Misc DSA Basic Coding Problems pattern-printing Practice Tags : Miscpattern-printing Similar Reads Program to print interesting pattern Program to print following pattern: ********1******** *******2*2******* ******3*3*3****** *****4*4*4*4***** ****5*5*5*5*5**** ***6*6*6*6*6*6*** **7*7*7*7*7*7*7** Examples : Input : 4 Output : ********1******** *******2*2******* ******3*3*3****** *****4*4*4*4***** Input :5 Output : ********1******** 9 min read Programs to print Interesting Patterns Program to print the following pattern: Examples : Input : 5Output:* * * * * * * * * ** * * * * * * ** * * * * ** * * ** ** ** * * ** * * * * ** * * * * * * ** * * * * * * * * *This program is divided into four parts.C++// C++ program to print // the given pattern #include<iostream> using name 15+ min read Program to Print a Pattern of Numbers The idea of pattern based programs is to understand the concept of nesting of for loops and how and where to place the alphabets / numbers / stars to make the desired pattern.Write to program to print the pattern of numbers in the following manner using for loop 1 232 34543 4567654567898765In almost 8 min read How to learn Pattern printing easily? The task is to print a pattern as shown in the example for a given integer value.The goal is not to print just this one pattern, it is to learn the best approach to solve this kind of problems as these questions are frequently asked in coding exams and in job interviews.Examples: Input: N = 4 Output 12 min read Program to print the Cot Bed Pattern The given task is to draw the Cot Bed pattern using '$' Cot Bed Pattern: $$$$$$$$$$$$$$$$$$$$$$$$$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $$$$$$$$$$$$$$$$$$$$$$$$$ Below is the code to implement the above problem: Program: C++ // C++ program to print // the Cot 10 min read Like