Search
 
SCRIPT & CODE EXAMPLE
 

CPP

count number of prime numbers in a given range in c

#include <iostream>
using namespace std;
int main()
{
    int n1=0,n2=100,count=0;
    for(int i=n1;i<=n2;i++)
    {
        int c=0;
        for(int j=1;j<=i;j++)
        {
            if(i%j==0)
            {
                c++;
            }
        }
        if(c==2)
        {
            count++;
        }
    }
    cout<<count;
    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: create matrix cpp 
Cpp :: array of Methods c++ 
Cpp :: how to create 2d array using vector in c++ 
Cpp :: c++ get pointer from unique_ptr 
Cpp :: c++ check if debug or release visual studio 
Cpp :: swap in cpp 
Cpp :: C++ String Compare Example 
Cpp :: how to make a square root function in c++ without stl 
Cpp :: template c++ 
Cpp :: sum array c++ 
Cpp :: c++ array pointer 
Cpp :: do while c++ 
Cpp :: take a function as an argument in c++ 
Cpp :: put text on oled 
Cpp :: uparam(ref) 
Cpp :: reference c++ 
Cpp :: resharper fold if statement 
Cpp :: max c++ 
Cpp :: find the graph is minimal spanig tree or not 
Cpp :: c++ garbage collection 
Cpp :: ascii allowed in c++ 
Cpp :: C++ detaching threads 
Cpp :: casting to a double in c++ 
Cpp :: erase range vector c++ 
Cpp :: new in c++ 
Cpp :: Program to find GCD or HCF of two numbers c++ 
Cpp :: pointer to pointer c++ 
Cpp :: error in c++ 
Cpp :: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ 
Cpp :: recuva recovery software for pc with crack 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =