Join WhatsApp Channel Join Now
Join WhatsApp Group Join Now
Telegram Channel Join Now

Monday 16 March 2015

Write A Program To How To Find Whether Given Number Is Prime Number Or Not - in Easiest Way

In Last article Freshers Junction explain “How to write a Prime Number Program”. In that article freshers junction clearly explained What is prime number, how to write prime number program in easiest way. Now in this article Freshers Junction blog explain Prime Number program to check whether it is prime or not in the Easiest Way. These Both questions are frequently asked question in Technical Interview. And also you can remember these two prime numbers are basic C programs, you should know these walkins before attending Interview.

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

In the above program, we initially initialize C as integer 2.
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.

0 comments:

 
close

Join Telegram Channel

Join FreshersJobsUpdates - Your Job Search End Here

Join Telegram Channel