write a Java program to print all the prime numbers between 1 to100
Answers
Answered by
6
Answer:
import java.util.*;
Class prime
{
public static void main()
{
Scanner sc =new Scanner(System.in);
int i , j, c=0 ;
for( i=1 ; i<=100; i++)
{
for( j=1 ; j< =i ; j++)
{
if ( i%j ==0)
c++;
}
if ( c==2)
System.out.println( " prime number is " + i);
c=0;
}
}
}
Similar questions
Science,
5 months ago
Geography,
10 months ago
Chemistry,
10 months ago
Psychology,
1 year ago
Physics,
1 year ago