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

Number Series-1

Here you can find all type of number series programs (if i miss any series please send me in Here)

Program: 1
public class HelloWorld{
     public static void main(String []args){
        for(int i=1;i<=5;i++){
            for(int j=1;j<=5;j++){
                System.out.print(j);
            }
            System.out.println("");
        }
     }
}
Output:
1  2  3  4  5
1  2  3  4  5
1  2  3  4  5
1  2  3  4  5
1  2  3  4  5
Program: 2
public class HelloWorld{
     public static void main(String []args){
        for(int i=1;i<=5;i++){
            for(int j=1;j<=5;j++){
                System.out.print(i);
            }
            System.out.println("");
        }
     }
}
Output:
1  1  1  1  1
2  2  2  2  2
3  3  3  3  3
4  4  4  4  4
5  5  5  5  5
Program: 3
public class HelloWorld{
     public static void main(String []args){
        for(int i=1;i<=5;i++){
            for(int j=1;j<=i;j++){
                System.out.print(i);
            }
            System.out.println("");
        }
     }
}
Output:
1
2  2
3  3  3
4  4  4  4
5  5  5  5  5
Program: 4
public class HelloWorld{
     public static void main(String []args){
        for(int i=1;i<=5;i++){
            for(int j=1;j<=i;j++){
                System.out.print(j);
            }
            System.out.println("");
        }
     }
}
Output:
1
1  2
1  2  3
1  2  3  4
1  2  3  4  5
Program: 5
public class HelloWorld{
     public static void main(String []args){
        for(int i=1;i<=5;i++){
            for(int j=i;j<=5;j++){
                System.out.print(i);
            }
            System.out.println("");
        }
     }
}
Output:
1  1  1  1  1
2  2  2  2
3  3  3
4  4
5




No comments:

Post a Comment