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 Aug 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

Stress and Strain

Arnab Bhattacharjee

0 0
0

Protocol: Preparation for Ultra competent cells of E.Coli DH5-alpha
Preparation: Prepare LB media and Transformation Buffer. Transformation Buffer 10 mM Hepes15 mM CaCl2250 mM KCl (pH to 6.7 with KOH)MIX Thoroughly with constant stirring and than add 55 mM MnCl2 and...

How to score better?
Do you ever wonder why the different students studying in the same classroom, taught by the same teacher get different marks (taken into consideration that the comparison is accounting for sincere students)?...

Limit, Fit, Tolerance

Arnab Bhattacharjee

0 0
0

Lets Talk About Software Design-patterns
What are Design Patterns? Design Pattern is a used and tested solution for a known problem. In simple words, you can say a general reusable solution to a commonly occurring problem within a given context...

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