import java.util.Scanner;
public class PatternBox
{
public static void main(String[] args) {
for (int i = 1; i <= 10; i++)
{
for (int j = 1; j <= 10; j++)
{
if (i==1 || i==10 || j==1 || j==10 )
System.out.print(" 1");
else
System.out.print(" ");
}
System.out.println();
}
}}
Python
def box(r, c) :
for i in range(1, r+1) :
for j in range(1, c+1) :
if (i == 1 or i == r or
j == 1 or j == c) :
print("1"),
else :
print(" "),
print(" ")
rows = 6
columns = 10
box(rows, columns)
C program
#include <stdio.h>
int main()
{
for (int i = 1; i <= 10; i++)
{
for (int j = 1; j <= 10; j++)
{
if (i==1 || i==10 || j==1 || j==10 )
printf(" 1");
else
printf(" ");
}
printf("\n");
}
}
C# program
using System;
public class Program
{
public static void Main()
{
int row, i, j;
row = 5;
for (i = 0; i <= 10; i++)
{
for (j = 0; j <= 10 ; j++)
{
if (i == 0 || i == 10 || j == 0 || j== 10)
Console.Write("1");
else
Console.Write(" ");
}
Console.WriteLine();
}
}
}
JAVA
Python
C program
C# program
PHP program
need an explanation for this answer? contact us directly to get an explanation for this answer