Skip to main content

Posts

Showing posts from January 25, 2020

Write a java program to print number divisible 3, 5

Write a java program to print number divisible 3, 5 In this java program, I'm going to print the number which is divisible by 3 , divisible by 5 and divisible by 3 and 5 both: package programlist; public class Numbers { public static void main(String[] args) { for(int i=1; i<=1; i++) { System.out.println("Divisable by 3"); for(int l=1; l<=50; l++) { if(l%3==0) { System.out.println(l); } } System.out.println("Divisable by 5"); for(int j=1; j<=50; j++) { if(j%5==0) { System.out.println(j); } } System.out.println("Divisable by 3 & 5"); for(int k=1; k<=50; k++) { if(k%3==0 && k%5==0) { System.out.println(k); } } } } } OutPut: Divisable by 3 3 6 9 12 15 18 21 24 27 30 33 36 39 42 45 48 Divisable by 5 5 10 15 20 25 30 35 40 45 50 Divisable by 3 & 5 15 30 45

Java Program : Write a program to print Fibonanci

Java Program : Write a program to print Fibonanci package programlist; public class Fibonanci { public static void main(String[] args) { int sum; int a=0; int b=1; System.out.println(a); System.out.println(b); for(int i=1; i<=10; i++) { sum=a+b; a=b; b=sum; System.out.println(b); } } } Output:  0 1 1 2 3 5 8 13 21 34 55 89

Java Program: Write a program to Print A to Z

Java Program: Write a program to Print A to Z Below os the code to print A to Z: package programlist; public class AtoZ { public static void main(String[] args) { for(char i='A'; i<='Z'; i++) { System.out.print(i+" "); } } } Output: