Search
 
SCRIPT & CODE EXAMPLE
 

CPP

prime or not in cpp

// prime or not

#include <iostream>
using namespace std;

int main()
{
    int num, i, counter = 0;

    cout<< "Enter the number : ";
    cin>> num;

    for(i=2; i<num; i++)
    {
        if (num % i == 0)
            counter ++;
    }

    if(counter != 0)
        cout<< "Composite";
    else
        cout<< "Prime";

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: bfs to detect cycle in undirected graph 
Cpp :: cpp linked list 
Cpp :: string reverse iterator c++ 
Cpp :: calculator in cpp 
Cpp :: lower bound and upper bound in c++ 
Cpp :: sort strings by length and by alphabet 
Cpp :: how to grab each character from a string 
Cpp :: how to input in cpp 
Cpp :: c++ template vs code 
Cpp :: initialise 2d vector in c++ 
Cpp :: User defined functions and variables in C++ programming 
Cpp :: create new node in tree 
Cpp :: c++ code executio canntot proceed because glew32.dll was not founud 
Cpp :: cmake g++ address sanitizer 
Cpp :: what library is rand in c++ 
Cpp :: find vector size in c++ 
Cpp :: c++ pop string from vector 
Cpp :: cout stack in c++ 
Cpp :: count number of char in a string c++ 
Cpp :: find nth fibonacci number 
Cpp :: C++ to specify size and value 
Cpp :: cpp vector structure 
Cpp :: cin c++ 
Cpp :: heap allocated array in c ++ 
Cpp :: c++ initialize size of 3d vector 
Cpp :: kmp c++ 
Cpp :: cpprestsdk send file 
Cpp :: HMC 5883 Example to return x y z values 
Cpp :: how to run cpp in visual studio 
Cpp :: how does sorting array works in c++ 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =