Pattern Program: #1

 

Pattern Program: #1



OutPut: Using Do while Loop in Java

*******

*        *

*        *

*        *

*        *

*        *

*******



class Demo1 {


public static void main(String[] args) {

int x=1,y;

do

{

y=7;

do

{

if(x==1 || x==7 || y==1 || y==7)

{

System.out.print("*");

}

else

{

System.out.print(" ");

}

y--;

}while(y>=1);

System.out.println();

x++;

}while(x<=7);

}


}




OutPut: Using Do while Loop in C#

*******

       *

       *

       *

       *

       *

*******



class Demo1 {


public static void main(String[] args) {

int x=1,y;

do

{

y=7;

do

{

if(x==1 || x==7 || y==1 || y==7)

{

Console.Write("*");

}

else

{

Console.Write(" ");

}

y--;

}while(y>=1);

Console.WriteLine();

x++;

}while(x<=7);

}


}


OutPut: Using Do while Loop in C

*******

       *

       *

       *

       *

       *

*******





void main() {

int x=1,y;

do

{

y=7;

do

{

if(x==1 || x==7 || y==1 || y==7)

{

printf("*");

}

else

{

printf(" ");

}

y--;

}while(y>=1);

printf("\n");

x++;

}while(x<=7);

}



OutPut: Using Do while Loop in C++

*******

       *

       *

       *

       *

       *

*******





void main() {

int x=1,y;

do

{

y=7;

do

{

if(x==1 || x==7 || y==1 || y==7)

{

cout<<("*");

}

else

{

cout<<(" ");

}

y--;

}while(y>=1);

cout<<("\n");

x++;

}while(x<=7);

}

For More Information visit my Official website: www.sateeshm.com

Comments