I am trying to write a program to find nearest prime to a number to its left...using for loop
i just don't seem to get it right
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n1,flag=0;
cout<<"Enter The Number"<<endl;
cin>>n1;
for(int i=n1;i>0;i--)
{
for(int j=2;j<(i/2);j++)
{
if(i%j==0)
{
flag=0;
}
else if(flag=1)
{
cout<<i<<endl;
}
}
}
getch();
}