34) Write a program to input a number and
check whether it is Composite Number
or not?(Num is not Prime, called Composite)
import java.util.*;public class Composite_number{public static void main(String args[ ]){Scanner sc = new Scanner (System.in);System.out.println("Enter a number");int a = sc.nextInt();int c = 0;for(int i=1;i<=a;i++){if(a%i==0)c++;}if(c!=2){System.out.println("Entered number is a COMPOSITE number");}else{System.out.println("Entered number is not a COMPOSITE number");}}}
No comments:
Post a Comment
if you have any doubts, Please let me know.
Your Truly
Shashank Porwal