UrbanPro
true

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

Google Street View Cars Are Mapping Methane Leaks
Natural gas pipeline leaks that pose a safety hazard are quickly addressed. But what about leaks too small to pose a threat? These mall leaks are often overlooked and they collectively release tons of...

The Strategies that Set Top Students Apart
Study Tips 1: Focus on mastery Study Tips 2: Find the value for you Study Tips 4: Build your competence and gain confidence Study Tips 5: Think critically about what you’re learning Study Tips...

Piyush Chauhan

0 0
0

Variable Resistor Concept
•In electrical circuit, a switch is used to turn the electricity on and off just like a valve is used to turn the water on and off. •There are times when you want some water but don’t...

Mechanical Designing, Is it all about knowing CAD ?
Whenever, I get chance to meet and interview any mechanical designer, I could see they will be more interested to showcase themselves knowing more about a different mechanical CAD software it could be...

Product Design
Product DesignThere are three Main Point to Be Consider To Start Product Design: Functionality Mechanism Assembly These point is important role in any prodct design start .like :- mechanical parts, plastics parts, Sheetmetal Part.
A

Acad Design Solutation

0 0
0

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