1.
Introduction
2.
Problem Statement
3.
Solution
3.1.
Program in C++
3.2.
Program in C
3.3.
Program in Java
3.4.
Program in Python
4.
4.1.
Why are Patterns essential to learn?
4.2.
What Is A Design Pattern?
5.
Conclusion
Last Updated: Mar 27, 2024

# Cross Sign Pattern

Master Python: Predicting weather forecasts
Speaker
Ashwin Goyal
Product Manager @

## Introduction

Puzzles are good exercise for the brain. They help in enhancing the cognitive abilities of the brain helping with Problem Solving and related skills. There are numerous types of puzzles; each one having a logic inherent to itself which helps in cracking it. A good puzzle well is actually like a good mystery that we may have read about or watched on TV. It has the finest of hints which help in reaching its solution.

The following article discusses one such puzzle so let's get right to it.

## Problem Statement

Program to Print Cross Sign (â•ł ) Star Pattern.

Example

Input : n=5

Output:

``````*   *
* *
*
* *
*   *``````
Get the tech career you deserve, faster!
Connect with our expert counsellors to understand how to hack your way to success
User rating 4.7/5
1:1 doubt support
95% placement record
Akash Pal
Senior Software Engineer
326% Hike After Job Bootcamp
Himanshu Gusain
Programmer Analyst
32 LPA After Job Bootcamp
After Job
Bootcamp

## Solution

### Program in C++

The C++ Program to Print Cross Sign (â•ł) source code is available here. Star Pattern.

``````#include<iostream>
using namespace std;
int main()
{
cout<<"Enter the row size:";
int row_size;
cin>>row_size;
int in,out,p;
for(out=1;out<=row_size;out++)
{
for(in=1;in<=row_size;in++)
{
if(in==out || in+out==row_size+1)
{
cout<<"*";
}
else
{
cout<<" ";
}
}
cout<<"\n";
}
}

``````

Output:

``````Enter the row size:7
*     *
*   *
* *
*
* *
*   *
*     *``````

### Program in C

The C Program to Print Cross Sign (â•ł ) source code is available here, Star Pattern.

``````#include<stdio.h>
int main()
{
int out,in;
printf("Enter the row size:");
int row_size;
scanf("%d",&row_size);
for(out=1;out<=row_size;out++)
{
for(in=1;in<=row_size;in++)
{
if(in==out || in+out==row_size+1)
{
printf("*");
}
else
{
printf(" ");
}}
printf("\n");
}}``````

Input/Output:

``````Enter the row size:5
*   *
* *
*
* *
*   *``````

### Program in Java

The Java Program to Print Cross Sign (â•ł) Star Pattern source code is available here.

``````import java.util.Scanner;
public class StarPattern17 {

public static void main(String[] args) {
Scanner cs=new Scanner(System.in);
System.out.println("Enter the row size:");
int out,in;
int row_size=cs.nextInt();
for(out=1;out<=row_size;out++)
{
for(in=1;in<=row_size;in++)
{
if(in==out || in+out==row_size+1)
{
System.out.printf("*");
}
else
{
System.out.printf(" ");
}
}
System.out.println();
}
cs.close();
}
}``````

Input/Output:

``````Enter the row size:
5
*   *
* *
*
* *
*   *``````

### Program in Python

The Python Program to Print Cross Sign (â•ł) Star Pattern source code is available here.

``````row_size=int(input("Enter the row size:"))
print_control_x=row_size//2+1
for out in range(1,row_size+1):
for inn in range(1,row_size+1):
if inn==out or inn+out==row_size+1:
print("*",end="")
else:
print(" ", end="")
print("\r")``````

Input/Output:

``````Enter the row size:3
* *
*
* *``````

In all the above examples, the output will be a pattern in the form of a Cross Sign.

Input Format

The first line contains the row size of the pattern, while the other variables were for the internal and external of the pattern.

Output Format

We are printing the pattern in the form of a Cross Sign.

Check out this problem - Check If A String Is Palindrome

### Why are Patterns essential to learn?

Patterns help us make predictions of what will happen. Next, It helps us develop logical connections and improve our reasoning skills

### What Is A Design Pattern?

A design pattern is a general repeatable solution to a typically occurring problem in software design in software engineering. A design pattern isn't a finished design that can be turned into code right away. It's a description or template for solving an issue that may be applied to a variety of scenarios.

## Conclusion

In this article, we have learned the Cross Sign pattern using the stars. We also explained it works and how it will go through step by step. We also took the example and the output of the pattern.