Program to Print All Prime Numbers between 1 to 100 in Java by Deepak

Java

Video is ready, Click Here to View ×


visit my website to get all the java tutorials links (Chapter Wise) :
http://smartprogramming.in
—————————————————————————————————-
Contact to have all-in-one Java training with me.
Contact No : +91 62838-30308 (Whats App Also Available)
Email ID : smart.programming.2101@gmail.com
—————————————————————————————————-
Program to Print All Prime Numbers between 1 to…

30 thoughts on “Program to Print All Prime Numbers between 1 to 100 in Java by Deepak

  1. Sir what value does temp store? Is it the value of the remainder? Also in one of the if statements why if(temp == 0) then i that is the prime number is printed? If the remainder is 0 that means that the number was divisible right sir? Please explain! My exams are on Monday!

  2. sir my book says it…(below). my text Book's question is "print the series of the prime number up to 25, using nested for loop"
    is this program right or wrong..? I am from Bangladesh so please explain me with some easy Hindi.and what is "temp" you used in your program..?I will be so grateful to you.

    public class prime
    {
    public static void main(string args [])
    {
    int i j ;
    System.out.println("series of Prime number upto 25 is :n");
    for(i=2,i<=25;i++)
    {
    for (j=2;j<=i;j++)
    {
    if (i%j= =0)
    break;
    }
    if(i= =j)
    System.out.print(" "+i+" ");
    }
    }
    }

  3. Simple Armstrong Program IS Here
    package com.java.practice;

    import java.util.Scanner;

    public class ArmstrongNumber {

    @SuppressWarnings("resource")
    public static void main(String[] args) {

    Scanner scanner=new Scanner(System.in);

    System.out.println("Enter Number to check:");

    int number=scanner.nextInt();

    int r,rev=0;
    int save=number;
    while (number!=0)
    {
    r=number%10;
    rev=rev+r*r*r;
    number=number/10;
    }
    if(save==rev)
    {
    System.out.println("Armstrong");
    }
    else
    System.out.println("Not armstrong");
    }

    }

  4. For your kind information 1 is not prime ….The definition of a prime number is a positive integer that has exactly two positive divisors. However,1 only has one positive divisor (1itself), so it is not prime.

  5. Sir….. my solution
    import java.util.Scanner;
    public class Program
    {
    public static void main(String[] args) {
    Scanner obj=new Scanner(System.in);
    int x=obj.nextInt();
    int a=1;
    int d=2,e=0;
    while(a<=x){
    e=0;
    for(d=2;d<=a;d++){
    if(a%d==0){
    e++;
    }
    }
    if(e==1){
    System.out.print(a+", ");
    }
    a++;
    }
    }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *