Program:
// Program By http://solutionscpp.blogspot.com// Author Mansoor Ahmed
// GMail ID: secguy000@gmail.com
#include<iostream>
using namespace std;
int main()
{
int check,n=0,c=0;
cout<<"Enter Prime Number you want to Find: ";
cin>>n;
for(int i=2;i<=1000;i++)
{
check=0;
for(int j=2;j<=i/2;j++)
{
if(i%j==0)
{
check=1;
break;
}
}
if(check==0)
c++;
if(c==n)
{
cout<<n <<" Prime Number is: " <<i;
break;
}
}
return 0;
}
sir why this program dose not execute 10001th prime number???
ReplyDeleteTHANK YOU, THIS PROGRAM HELPS ME TO FINISH MY MIPS PROGRAM HOMEWORK
ReplyDeleteThis code is helpful but I want some Example of C++ Programs;
ReplyDeletePrint Star pattern in C++
Print number pattern in C++
Prime number program in C++
Factorial Program in C++
I found nice article in your blog.thank you for useful info
ReplyDelete.
Can anyone tell me why is it necessary to initialize check variable inside for loop only...
ReplyDeleteBecause in my program I had written check variable outside and before for loop but it did not give me the output
Represent 2 in that form !
ReplyDeletethanks
ReplyDelete