to write a program in c++ in which we have to print the prime numbers up to the input no. using for loop only?

By Amerina#include<iostream.h>
#include<conio.h>
void main()
{
int i,j,ip,k;
clrscr();
cout<<"GIVE THE INPUT";
cin>>ip;
for(i=0;i<=ip;i++)
{
for(j=2;j<=i-1;j++)
{
if(i%j==0)
break;
}
if(i==j)
cout<<"\t"<<i;
}
getch();
}

#include
#include
void main()
{
clrscr();
int num,ctr;
cout<<"enter number";
cin>>num;
for(int i=1;i<=num;i++)
{
for(int j=i;j<=i;j++)
{
if(i%j==0)
ctr++;}
if (ctr==2) //prime nos. have only 2 factors
cout<<'\n'< }
getch();
}
hi! below please find your complete program ::::

// To find the first 10 prime numbers
#include
#include
void prime(int i, int c, int n, int j) /* This function can be used to find prime numbers to any extent ( first 10 here) by simply changing the while statement */
{
while (c <=10)
{
n=0;
i +=1;
for (j=1 ; j<=i ; j++ )
{
if ( i%j == 0)
{
n +=1;
}
}
if (n <=2 && n != 0)
{
cout< c +=1;
}

}
}
void main()
{
int i=0,c=1,n,j;
prime(i,c,n,j);
cout<<"\n\nPress ENTER to close this Window";
getch();
}


You can Modify the value of 'C' from 10 to 100 for first 100 prime numbers...