Your SlideShare is downloading. ×
//Ques. 1 WAP to find out whether the number is prime or not ?

importjava.util.Scanner;
class prime
{
public static void ...
OUTPUT :-
Upcoming SlideShare
Loading in...5
×

WAP to find out whether the number is prime or not in java

297

Published on

WAP to find out whether the number is prime or not in java

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
297
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "WAP to find out whether the number is prime or not in java"

  1. 1. //Ques. 1 WAP to find out whether the number is prime or not ? importjava.util.Scanner; class prime { public static void main(String arr[]) { intn,c=1,i=2; Scanner in = new Scanner(System.in); System.out.print("n Enter a Number = "); n = in.nextInt(); for (i=2;i<=2;i++) { if (n%2==0||n%3==0) { c=0; break; } } if (c==1) System.out.println( n+ " is Prime Number"); else System.out.println(n+ " is not a Prime Number"); } }
  2. 2. OUTPUT :-

×