optput its not proper
i am tring to print 1 to n given number prime number
plese solved error.....

#include<stdio.h>
#include<conio.h>
int main()
{
int a,b=2,c,n;

printf("enter n");
scanf("%d",&n);

for(a=2;a<=n;a++)
{ 
    b=2;    
    c=1;         
   while(b<a)
   {
      if(a%b==0)
      {
         c=0;
         break;
      }

       b++;
    }


if(c!=0)
{
     printf("\n%d",a);
}


}
getch();
}

Firstly, start using a better IDE then Turbo because it will help you to have good interface to make codes. Turbo is okay, but if you want to improve I will suggest you to start using DevC++, Codeblocks, Visual-studio etc.

secodnly, your code is correct but has some initialization problems which i have corrected and posted above. I hope this will help you. thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.