c++ find prime numbers
C++
#include <iostream>
using namespace std;
int main()
{
int n, i;
bool isPrime = true;
cout << "Enter a positive integer: ";
cin >> n;
for(i = 2; i <= n / 2; ++i)
{
if(n % i == 0)
{
isPrime = false;
break;
}
}
if (isPrime)
cout << "This is a prime number";
else
cout << "This is not a prime number";
return 0;
}
Also in C++:
- Title
- what are the different ways to traverse a binary tree
- Category
- C++
- Title
- c++ convert int to cstring
- Category
- C++
- Title
- #include
- Category
- C++
- Title
- memset c++
- Category
- C++
- Title
- sort function in c++
- Category
- C++
- Title
- goto c++
- Category
- C++
- Title
- inserting an element in an set c++
- Category
- C++
- Title
- opencv compile c++
- Category
- C++
- Title
- how to find the mode of a vector c++
- Category
- C++
- Title
- knapsack
- Category
- C++
- Title
- how to find the number of cycles in a graph C++
- Category
- C++
- Title
- matrix eigen c++ example
- Category
- C++
- Title
- Merge k sorted linked lists and return it as one sorted list.
- Category
- C++
- Title
- c++ set add element
- Category
- C++
- Title
- getline in c++
- Category
- C++
- Title
- C++ int to char*
- Category
- C++
- Title
- ios_base::sync_with_stdio(false);cin.tie(NULL);
- Category
- C++
- Title
- declaring 2d vector in c++
- Category
- C++
- Title
- linear search in c++
- Category
- C++
- Title
- make an x using asterisk c++
- Category
- C++
- Title
- c++ transform
- Category
- C++
- Title
- c++ string to vector int
- Category
- C++
- Title
- nginx linux
- Category
- C++
- Title
- private and public in namespace cpp
- Category
- C++
- Title
- Runtime Error: Runtime ErrorAbort signal from abort(3) (SIGABRT)
- Category
- C++
- Title
- minimum swaps to sort an array
- Category
- C++
- Title
- deque c++
- Category
- C++
- Title
- arrays in C++
- Category
- C++
- Title
- c++ excel blank cells
- Category
- C++
- Title
- How to find the suarray with maximum sum using divide and conquer
- Category
- C++
- Title
- floor() in c++
- Category
- C++
- Title
- c++ for loop syntax
- Category
- C++
- Title
- cpp loop through object
- Category
- C++
- Title
- never gonna give you up lyrics
- Category
- C++
- Title
- c++ push multiple elements to vector
- Category
- C++
- Title
- leveling system c++
- Category
- C++
- Title
- how to avoid tle in c++
- Category
- C++
- Title
- initialize int c++
- Category
- C++
- Title
- git branch in my bash prompt
- Category
- C++
- Title
- how to output to console c++
- Category
- C++
- Title
- making random numbers in c++
- Category
- C++
- Title
- how to show c++ binary files in sublime text
- Category
- C++
- Title
- how to iterate trough a vector in c++
- Category
- C++
- Title
- compile c++ linux
- Category
- C++
- Title
- c++ triple
- Category
- C++
- Title
- check if key exists in map c++
- Category
- C++
- Title
- how to make a heap using stl in c++
- Category
- C++
- Title
- c++ get length of array
- Category
- C++
- Title
- double max value c++
- Category
- C++
- Title
- function declerations in C++
- Category
- C++
- Title
- c++ cli convert string to string^
- Category
- C++
- Title
- arduino falling edge
- Category
- C++
- Title
- append string to another string c++
- Category
- C++
- Title
- sort a pair using c++ stl
- Category
- C++
- Title
- c++ crash windows
- Category
- C++
- Title
- to_string c++
- Category
- C++
- Title
- split string at index c++
- Category
- C++
- Title
- powers of 2 in cpp
- Category
- C++
- Title
- c++ read matttrix from text file
- Category
- C++
- Title
- pass by reference c++
- Category
- C++
- Title
- accumulate in cpp
- Category
- C++
- Title
- body parser
- Category
- C++
- Title
- How to check if a triangular cycle exists in a graph
- Category
- C++
- Title
- How to read a file in in C++
- Category
- C++
- Title
- monotonic deque
- Category
- C++
- Title
- coping 2d vector in cpp
- Category
- C++
- Title
- char **
- Category
- C++
- Title
- unsorted array to bst
- Category
- C++
- Title
- memcmp in cpp
- Category
- C++
- Title
- Html tabulation
- Category
- C++
- Title
- restting a queue stl
- Category
- C++
- Title
- cout console
- Category
- C++
- Title
- sum of integer in array c++
- Category
- C++
- Title
- expected unqualified-id before 'if'
- Category
- C++
- Title
- c++ how to return an empty vector
- Category
- C++
- Title
- C++ Syntax
- Category
- C++
- Title
- ceil c++;
- Category
- C++
- Title
- c++ string to int
- Category
- C++
- Title
- int to float c++
- Category
- C++
- Title
- sort a string alphabetically c++
- Category
- C++
- Title
- initialising 2d vector
- Category
- C++
- Title
- c++ tutorial
- Category
- C++
- Title
- transpose matrix eigen c++
- Category
- C++
- Title
- c++ delete dynamically allocated array
- Category
- C++
- Title
- unordered_set in c++ and ordered set diff
- Category
- C++
- Title
- how to have a queue as a parameter in c++
- Category
- C++
- Title
- C++ pointer arithmetic
- Category
- C++
- Title
- chess perft 5
- Category
- C++
- Title
- differentialble programming
- Category
- C++
- Title
- c++ ambigous error
- Category
- C++
- Title
- cloud hosting
- Category
- C++
- Title
- convert int to binary string c++
- Category
- C++
- Title
- convert decimal to binary in c++
- Category
- C++
- Title
- least number of coins to form a sum
- Category
- C++
- Title
- cut by delimiter c++
- Category
- C++
- Title
- new class * [] c++
- Category
- C++
- Title
- c++ comment
- Category
- C++
- Title
- pbds in c++
- Category
- C++
- Title
- fill c++
- Category
- C++
- Title
- c++ find object in vector by attribute
- Category
- C++