What is Prime number:Prime numbers means “The Number which is divisible by only 1 or itself ”. The Examples for prime numbers is 13,17,19,23 etc. Here you can notice all these numbers are not divisible by any other number except 1 and itself.
Prime Number program to check whether it is prime or not
After This Printf Prints a “Enter a number to check if it is prime” line
Scanf function reads the Input n value from user.
Now here we are using for loop, here we check the given number is prime number or not
Example: if the input from user is 15. Then initially 15 is divided by 2 (because we initialize C Value as 2) if the result is 0 then the given number is not prime. But 15/2 is 1, now the loop is again executed. Now C value is incremented by 1 (Due to c++). So now 15/3 is checked. This time result is 0. So the Given number is Not a Prime Number.
Conclusion: If you have any queries about prime numbers program, comment here. We provide best solution to your questions.
Note: “Difference Between Method Overloading and Method Overriding in .Net/ JAVA” is also one most important question for Technical Interview.
Use Ctrl+D to bookmark this page to see whenever you want
You Can Search in Google also like:
How to find given number is Prime Number or not. Prime Numbers program in C, easiest Prime number program, check given number prime or not, All types of Prime Numbers program, prime number program using single for loop. How to find whether given number is prime number or not easiest way.