Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C language #129

Open
Shiva-0108 opened this issue Apr 12, 2022 · 0 comments
Open

C language #129

Shiva-0108 opened this issue Apr 12, 2022 · 0 comments

Comments

@Shiva-0108
Copy link

// C++ program to print square inside
// a square pattern
#include
using namespace std;

// Function to print the pattern square
// inside a square
void printPattern(int n)
{
int i, j;

// To access rows of the square
for (i = 1; i <= n; i++)
{
	// To access columns of the square
	for (j = 1; j <= n; j++)
	{

		// For printing the required square pattern
		if ((i == 1 || i == n || j == 1 || j == n) ||
			(i >= 3 && i <= n - 2 && j >= 3 && j <= n - 2) &&
			(i == 3 || i == n - 2 || j == 3 || j == n - 2))
		{
			// Prints star(*)
			cout<<"*";
		}
		else
		{
			// Prints space(" ")
			cout<<" ";
		}
	}

	cout<<endl;
}

}

// Driver Code
int main()
{
int n = 7;
printPattern(n);
return 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant