0% found this document useful (0 votes)
38 views1 page

Prime Numbers 1

Uploaded by

iirwed79
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views1 page

Prime Numbers 1

Uploaded by

iirwed79
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Write a C++ program that shows prime numbers from 1-1000?

// prime numbers from 1 to 1000 ..


#include <iostream>
using namespace std;
int main()
{
int number, i;
for(number=1; number<=1000; number++)
{
for(i=2; i<number; i++)
{
if(number%i==0)
break;
}
if(number==i)
{
cout<<number<<" a Prime Number"<<endl;
}
else
{
cout<<number<<" Not a Prime Number"<<endl;
}
}
}

You might also like