• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
May 17, 2022 |76.2K Views
C++ Program to Print Prime Numbers between 1 to 100
  Share   Like
Description
Discussion

In this video, we will see how to print prime numbers from 1 to 100. We know that “A prime number is a number that can only be divided by itself and 1 without remainders”. There are 25 prime numbers between 1 to 100.[2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97]

Algorithm to Print Prime Numbers:

First, take the numbers from 1 to 100 as input. Then use a for loop to iterate the numbers from 1 to 100. Then check for each number to be a prime number. If it is a prime number, print it.

Here, we created a program using the three different loop procedures:
1. Loop [2 to N]
2. Loop [2 to sqrt (N)]
3. Loop [2 to N/2]

Program to Print Prime Numbers between 1 to N: https://www.geeksforgeeks.org/program-to-print-first-n-prime-numbers/

Read More