Simple math in C++: Difference between revisions

wikademia>Nirdh
added a sample program
wikademia>Wikademia
 
(2 intermediate revisions by 2 users not shown)
Line 86: Line 86:
----
----


/*This program finds prime numbers between 1 and number provided by user*/
<code><pre>
<code><pre>
#include<iostream.h>
#include<iostream>
#include<conio.h>
using namespace std;
#include<stdio.h>
int main(){
void main()
int n;
{
cin>>n;
clrscr();
for(int i=2;i<n;++i){
unsigned int a,i,n,x;
int count=0;
cout<<"This program is developed by Nirdh... press enter to continue.";
for(int j=1;j<=n;++j)
cout<<"Enter a number till which prime numbers are wanted: ";
if(!(i%j))
cin>>a;
++count;
for(x=1;x<a+1;x++)
if(count==2)
{
cout<<i<<endl;
  n=0;
}
  for(i=1;i<=x;i++)
return 0;
  {
  if(x%i==0)
  {
    n=n+1;
  }
  else
  {
    n=n;
  }
  }
  if(n<3)
  {
  cout<<x<<"\t";
  }
}
getch();
}
}
</pre></code>
</pre></code>


--[[User:Nirdh|Nirdh]] 11:36, 5 April 2009 (UTC)


----
----


==Where To Go Next==
==Where To Go Next==