# Make an algorithm and a program to get an integer from the user as an input and classify it as prime number or non-prime number .(language : c/c++)

2
Log in to add a comment

Log in to add a comment

The Brainliest Answer!

====> in java <====

............................

import java.util.*;

{

public static void main(String arg[])

{

Scanner sc = new Scanner (System.in);int n,i,c=0;

System.out.println("Enter a Number");

n=sc.nextInt();

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

{

n=n%i;

c=c+1;

System.out.println("NOT!");

}}For eg;if the number given is 2

Output:

Prime Number

if the number given is 8

Output:

NOT!

......................................

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

{

n=n%i;

c=c+1;

System.out.println("NOT!");

}}For eg;if the number given is 2

Output:

Prime Number

if the number given is 8

Output:

NOT!