Go to Top

Tuesday, 2 August 2011

To print the given pattern

Question 24 : Write a program in Java to print the following pattern : 

12345
2345
345
45
5

Java Program : 

public class pattern_11
{
 public static void main()
 {
     int i,j;
     for(i=1;i<=5;i++)
     {
         for(j=i;j<=5;j++)
         {
             System.out.print(j);
            }
            System.out.print("\n");
        }
    }
}
 

1 comment:

  1. Nice................
    Basic C Program for Computer Programmer who want to learn. If you have simple wish you may visit. To get all update stay with us.
    Outline:
    • Language: C and Simscript.
    • if (Condition) statement and Nested if statement is used to determine the given number is positive, negative, even or odd. Another way we solve this program using if-else-if ladder.
    • When the given condition or expression is true the statement associated with it executed.
    To know details:

    http://www.secufoon.com/write-a-c-program-for-determining-a-number-is-positive-negative-even-or-odd/

    ReplyDelete

ShareThis