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
1 day ago 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

Current and voltage distribution
a) A current flowing in a wire of a length related to the RF produces an electromagnetic field. This field radiates from the wire and is set free in space. The principles of radiation of electromagnetic...

General Principles of Measurement...
Measurement is the process by which one can convert physical parameters into meaningful numbers. The measurement of a given quantity is the result of comparison between the quantity to be measured, and...

Calorimetry

Arnab Bhattacharjee

0 0
0

Tips For Writing The Examination And How To Score High Marks In The Examination
1. Write the question number on left hand side of the answer booklet very clearly, generally a large one focused to the evaluater, from the question paper.You can start writing the answer for any of the...

smart work with patience creates victory
In a village named ramapuram aa unemployee gopi lives. He is in search of job, roaming without food from a week. He decided to sell the wooden sticks by chopping the tree, he started chopping the trunk...

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