UrbanPro
true
default_background

Take BSc Tuition from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Data Structure and Algorithms check whether the given number is prime or not

Sahas Yadandla
20/08/2025 0 0

In this video, we’ll learn how to write a simple program in C++ to check whether a given number is prime or not.
The program takes an input number from the user, applies a loop to test divisibility, and then tells if it’s a prime number or not prime.

📌 What you’ll learn in this video:

  • What a prime number is (a number divisible only by 1 and itself).

  • How to use loops and conditions in C++.

  • Why for (int i = 2; i * i <= num; i++) is used for optimization.

  • Common mistakes to avoid while writing the logic.

🖥️ Program Explanation:

  1. User enters a number.

  2. If the number is ≤ 1, it’s not prime.

  3. Use a loop to check divisibility from 2 up to √n.

  4. If divisible, mark as not prime; otherwise, it’s a prime number.

0 Dislike
Follow 1

Please Enter a comment

Submit

Other Lessons for You

Revision
The efficiency of Diesel cycle depends upon(A) Temperature limits(B) Pressure ratio(C) Compression ratio(D) Cut-off ratio and compression ratio The efficiency of the Carnot cycle is (where T1and T2= Highest...

Semiconductors in a nutshell
What are semiconductors? Semicondutcors are substances which have conductivity in between conductors and insulators. Example: Germanium and Silicon. What are the types of semiconductors? Intrinsic semiconductors:...

Tracked Robots
Tracks (or treads) are what tanks use. Although tracks do not provide added “force” (torque), they do reduce slip and more evenly distribute the weight of the robot, making them useful for...

The Basic about modeling anything into CAD
The most basic problem that a beginner designer faces is - " From where to start" Have you ever wondered while starting to design an object to where should I start from or How am I suppose to know...

Database Genral Interview question
Q: What is SQL? A: SQL stands for 'Structured Query Language'. Q: What is SELECT statement? A: The SELECT statement...

Looking for BSc Tuition ?

Learn from Best Tutors on UrbanPro.

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for BSc Tuition Classes?

The best tutors for BSc Tuition Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Take BSc Tuition with the Best Tutors

The best Tutors for BSc Tuition Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more