TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Program to Print Pattern 12

Program to Print Pattern 12 on fibonacci, factorial, prime, armstrong, swap, reverse, search, sort, stack, queue, array, linkedlist, tree, graph, pattern, string etc.

<< Back to PROGRAM

Program to print the following pattern

Program to print the following pattern

Algorithm

  1. Start
  2. Let i be an integer number.
  3. Let j be an integer number.
  4. Repeat step 5 to 8 until all value parsed.
  5. Set i = 0 and check i<10;
  6. Set j = 0 and check j <= 10;
  7. Check conditions if(i==0 or i==10 or j==0 or j==10)
  8. If true print ?1? else print space.
  9. End

JAVA

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();
         }  
}
}

PHP program

        for ($i = 1; $i <= 10; $i++) 
    { 
        for ($j = 1; $j <= 10; $j++) 
        { 
            if ($i==1 || $i==10 || $j==1 || $j==10 )  
              {
                
                echo "1";
              }
            else
               {
                echo " ";
               }
        } 
        echo "<br>"; 
    }





Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf