VB icon

Prime Number Checker Using Classes in C++

Email
Submitted on: 8/31/2015 3:34:29 AM
By: Jake R. Pomperada  
Level: Beginner
User Rating: Unrated
Compatibility: C++ (general)
Views: 4546
author picture
 
     A simple program that I wrote a long time ago while learning C++ object oriented programming I called this program prime number checker using classes in C++ that will ask the user to enter a number and then our program will check if the number given is prime number or not a prime number. If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at my mobile number 09173084360. Thank you very much and Happy Programming.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Prime Number Checker Using Classes in C++
// Description:A simple program that I wrote a long time ago while learning C++ object oriented programming I called this program prime number checker using classes in C++ that will ask the user to enter a number and then our program will check if the number given is prime number or not a prime number.
If you have some questions about programming, about my work please send mu an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com. People here in the Philippines can contact me at my mobile number 09173084360.
Thank you very much and Happy Programming.
// By: Jake R. Pomperada
//**************************************

#include <iostream>
using namespace std;
class prime {
 public:
int n;
int smalldiv (int n) {
 int count;
 count = 2;
 while (count < n && n % count != 0) {
count = count + 1;
 }
 return(count);
}
};
 main () {
 prime value;
 cout << "\t Prime Number Checker 1.0";
 cout << "\n\n";
while (1) {
cout << "\n";
cout << "Enter a number: ";
cin >> value.n;
if (value.n == 0) {
cout << "\n\n";
cout << "Thank you for using this Program.";
break;
}
cout << "\n";
if (value.n == value.smalldiv(value.n)) {
cout << value.n << " is a prime number" << endl;
}
else {
cout << value.n << " is not a prime number" << endl;
}
 }
 cout << "\n\n";
 system("pause");
 }


Other 84 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.