wap to input values into 4×4 array and display all prime numbers
plz answer and i will mark u brainliest
Answers
Answer:
Please specify the languages also, I am giving Anwer in Java.
import java.util.Scanner;
class Prime
{
public static boolean isPrime(int num)
{
for (int i=2 ; i < num ; i++)
{
if (num % i == 0)
{
return false;
}
}
return true;
}
public static void main(String[] args)
{
int size[][] = new size[4][4];
Scanner in = new Scanner(System.in);
for (int col = 0 ; col < 4 ; col++)
{
for (int row = 0 ; row < 4 ; row++)
{
size[col][row] = in.nextInt();
}
}
for (int l = 0 ; l < 4 ; l++)
{
for (int r = 0 ; r < 4 ; r++)
{
if (isPrime(size[l][r]))
{
System.out.println(size[l][r]);
}
}
}
}
}