/*Program for checking whether ENTERED NUMBER is Prime or Composit*/ #include<iostream> using namespace std; int main() { unsigned int i, num; bool a = 0; cout << "Enter any non-negative Number?\t"; cin >> num; for (i = 2; i <= num - 1; i++) { if (num % i == 0) { a = 1; break; } } if (a != 1) cout << "Entered number is Prime\n"; else cout << "Entered number is Composit\n"; return 0; }
This blog is about coding in some commonly used "High Level Languages" like C, C++, Java etc. At first, I will post here basic programs written in C++ language only.
Friday, November 21, 2014
C++ Program for checking whether the entered number is "Prime" or "Composite"
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment