Are You Feeling any difficulity while writing Core-Java Programs. Send those to me Here.

Series Programs-1

Program: 3
public class HelloWorld{
     public static void main(String []args){
        for(int i=0;i<10;i++){
            for(int j=10;j>i;j--){
                System.out.print("*");
            }
            System.out.println("");
        }
     }
}

Output:
*  *  *  *  *  *  *  *  *  *
*  *  *  *  *  *  *  *  *
*  *  *  *  *  *  *  *
*  *  *  *  *  *  *
*  *  *  *  *  *
*  *  *  *  *
*  *  *  *
*  *  *
*  *
*

Program: 4
public class HelloWorld{
     public static void main(String []args){
        for(int i=0;i<10;i++){
            for(int k=0;k<i;k++)
            System.out.print(" ");
            for(int j=10;j>i;j--){
                System.out.print("*");
            }
            System.out.println("");
        }
     }
}

Output:
*  *  *  *  *  *  *  *  *  *
    *  *  *  *  *  *  *  *  *
        *  *  *  *  *  *  *  *
            *  *  *  *  *  *  *
                *  *  *  *  *  *
                    *  *  *  *  *
                        *  *  *  *
                            *  *  *
                                *  *
                                    *




No comments:

Post a Comment