write a program to input a number and check number is composite or not .A number which have more than two factors is called composite number.​

Answers 2

Answer:  class composite{

static void check(int a)//a is the number to be checked

{int n=0;//n is number of a’s factors

for(int i=1;i<=a;i++){

if(a%i==0)

n++;}

if(n>2)

System.out.println(a+” is a composite number”);

else

System.out.println(a+” is a prime number”);

}}

Answer:

1-To check and display whether a number input by the user is a composite number or not.

A number is said to be composite, if it has one or more than one factors excluding 1 and the number itself.

Example: 4, 6, 8, 9…

2-To find the smallest digit of an integer that is input:

Sample input: 6524

Sample output: Smallest digit is 2

For an incorrect choice, an appropriate error message should be displayed.

If you know the answer add it here!

Can't find the answer?

Log in with Google

or

Forgot your password?

I don't have an account, and I want to Register

Choose a language and a region
How much to ban the user?
1 hour 1 day 100 years