Showing posts with label while loop. Show all posts
Showing posts with label while loop. Show all posts

Saturday, November 1, 2014

, , ,

number Pattern 1 by while loop


Code Box by while loop
--------------------------------
/*program to print number pattern square box by while loop

  12345
  12345
  12345
  12345
  12345

*/

class npat1w
{
public static void main(String a[])
{
int n,i,j;
i=1;
n=Integer.parseInt(a[0]);

while(i<=n)
{j=1;
        while(j<=n)
        {
        System.out.print(j);
        j++;
 }

System.out.print("\n");
i++;
}
}
}


Publisher: Brijmohan Lal Sahu - 1:54 AM
, , ,

Number Pattern 2 by while loop


Code Box by while loop
-----------------------------
/*program to print number pattern box by while loop

  1
  12
  123
  1234
  12345

*/

class npat2w
{
public static void main(String a[])
{
int n,i,j;
i=1;
n=Integer.parseInt(a[0]);

while(i<=n)
{j=1;
        while(j<=i)
        {
        System.out.print(j);
        j++;
 }

System.out.print("\n");
i++;
}
}
}

Publisher: Brijmohan Lal Sahu - 1:44 AM
, , , , , ,

Number Pattern 3 by while loop,


Code Box by while loop
-------------------------------
/*program to print number pattern  by while loop

  1
  22
  333
  4444
  55555

*/

class npat3w
{
public static void main(String a[])
{
int n,i,j;
i=1;
n=Integer.parseInt(a[0]);

while(i<=n)
{j=1;
        while(j<=i)
        {
        System.out.print(i);
        j++;
}

System.out.print("\n");
i++;
}
}
}

Publisher: Brijmohan Lal Sahu - 1:25 AM
, , , ,

Number Pattern 3 by do while loop


Code Box by do while loop
------------------------------
/*program to print number pattern  by do while loop

  1
  22
  333
  4444
  55555

*/

class npat3do
{
public static void main(String a[])
{
int n,i,j;
i=1;
n=Integer.parseInt(a[0]);

do
{j=1;
        do
        {
        System.out.print(i);
        j++;
}
while(j<=i);
System.out.print("\n");
i++;
}
while(i<=n);
}
}


Publisher: Brijmohan Lal Sahu - 1:22 AM
, , , ,

Number Pattern 4 by while loop


Code Box by while loop
-----------------------------
/*program to print star pattern square box by while loop

  11111
  22222
  33333
  44444
  55555

*/

class npat4w
{
public static void main(String a[])
{
int n,i,j;
i=1;
n=Integer.parseInt(a[0]);

while(i<=n)
{j=1;
        while(j<=n)
        {
        System.out.print(i);
        j++;
}

System.out.print("\n");
i++;
}

}
}

Publisher: Brijmohan Lal Sahu - 1:13 AM
, , ,

Number Pattern 5 by while loop


Code Box by while loop
--------------------------

/*program to print number pattern square box by while loop

  54321
  54321
  54321
  54321
  54321
  

*/

class npat5w
{
public static void main(String a[])
{
int n,i,j;
i=1;
n=Integer.parseInt(a[0]);

while(i<=n)
{j=n;
        while(j>=1)
        {
        System.out.print(j);
        j--;
}

System.out.print("\n");
i++;
}
}
}



Publisher: Brijmohan Lal Sahu - 1:03 AM
, , ,

Number Pattern 6 by while loop


Code Box by while loop
-------------------------
/*program to print star pattern square box by while loop

  55555
  44444
  33333
  22222
  11111
  

*/

class npat6w
{
public static void main(String a[])
{
int n,i,j;

n=Integer.parseInt(a[0]);
i=n;
while(i>=1)
{j=1;
        while(j<=n)
        {
        System.out.print(i);
        j++;
}

System.out.print("\n");
i--;
}
}
}


Publisher: Brijmohan Lal Sahu - 12:51 AM
, ,

Number Pattern 7 by while loop


Code Box by while loop
-------------------------
/*program to print star pattern square box by while loop

  1
  21
  321
  4321
  54321

*/

class npat7w
{
public static void main(String a[])
{
int n,i,j;
i=1;
n=Integer.parseInt(a[0]);

while(i<=n)
{j=i;
        while(j>=1)
        {
        System.out.print(j);
        j--;
}

System.out.print("\n");
i++;
}
}
}


Publisher: Brijmohan Lal Sahu - 12:39 AM

Thursday, October 30, 2014

, ,

Number Pattern 8 by while loop

CODE BOX
------------------------------------------------------------

/*program to print star pattern square box by while loop

  5
  54
  543
  5432
  54321

*/

class npat8w
{
public static void main(String a[])
{
int n,i,j;
n=Integer.parseInt(a[0]);
i=n;
while(i>=1)
{j=n;
        while(j>=i)
        {
        System.out.print(j);
        j--;
 }

System.out.print("\n");
i--;
}
}
}


Publisher: Brijmohan Lal Sahu - 6:06 AM
, ,

Number Pattern 9 by while loop

CODE BOX
-----------------------------------------------------


/*program to print star pattern square box by while loop

        1
       12
      123
     1234
    12345

*/

class npat9w
{
public static void main(String a[])
{
int n,i,j,k;
i=1;
n=Integer.parseInt(a[0]);

while(i<=n)
{j=n;
k=1;
        while(j>i)
        {
        System.out.print(" ");
        j--;
 }

        while(k<=i)
        {
        System.out.print(k);
 k++;
        }
System.out.print("\n");
i++;
}
}
}

Publisher: Brijmohan Lal Sahu - 5:55 AM
,

Number Pattern 10 by While Loop


-----------------------------------------------------------------------
/*program to print star pattern square box by while loop

        1
       21
      321
     4321
    54321

*/

class npat10w
{
public static void main(String a[])
{
int n,i,j,k;
i=1;
n=Integer.parseInt(a[0]);

while(i<=n)
{j=n;
 k=i;
        while(j>i)
        {
        System.out.print(" ");
        j--;
 }

        while(k>=1)
        {

        System.out.print(k);
        k--;
 }
System.out.print("\n");
i++;
}
}
}

Publisher: Brijmohan Lal Sahu - 5:35 AM

Sunday, September 22, 2013

, , , , , , ,

Perfect Number Checker Using while loop


Code Box
------------------

/*Program to check input number is 
perfect or not using while loop*/

class per_while
{
public static void main(String a[])
{
int i,j,k,sum,mul;
sum=0;
mul=1;
i=1;
k=Integer.parseInt(a[0]);

while(i<k)
{
if(k%i==0)
{
mul=mul*i;
sum=sum+i;
}
i++;
}

if(sum==mul && k==mul)
{
System.out.println("perfect");
}
else
{
System.out.println("Not perfect");
}
}
}


Publisher: Brijmohan Lal Sahu - 3:38 PM