Class 10 Notes Project - Java

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

//PROGRAM TO FIND WHETHER A NUMBER IS COMPOSITE NUMBER OR NOT

import java.util.Scanner;

public class Composite_Number

public static void main(String args[])

int n,c=0,i;

Scanner sc=new Scanner(System.in);

System.out.println("Enter any number");

n=sc.nextInt();

for(i=2;i<n;i++)

if(n%i==0)

c++;

if(c>=1)

System.out.println("Number is Composite Number");

else

System.out.println("Number is not a Composite Number");

You might also like