Computer Science, asked by jananik4017, 1 year ago

Example of if else program

Answers

Answered by Anonymous
0

Explanation:

The if statement evaluates the test expression inside the parenthesis ().

If the test expression is evaluated to true, statements inside the body of if are executed.

If the test expression is evaluated to false, statements inside the body of if are not executed.

Answered by Anonymous
1

Answer:

import java.util.*;

class Prime_no

{

   public static void main()

   {

       Scanner sc=new Scanner(System.in);

       System.out.println("Enter number of elements to be entered");

       int n=sc.nextInt();

       int a[]=new int[n];

       int f;

       System.out.println("Enter "+n+" elements");

       for(int i=0;i<n;i++)

       a[i]=sc.nextInt();

       System.out.println("Prime numbers:");

       for(int i=0;i<n;i++)

       {

           f=0;

           for(int j=1;j<=a[i];j++)

           {

               if(a[i]%j==0)

               f++;

           }

       if(f==2)

           System.out.println(a[i]);

       }

   }

}

Similar questions