Coding:
#include<stdio.h>
#include<conio.h>
void main()
{
   int n,i=1,j,c;
   clrscr();
   textcolor(10);
   cprintf("\nEnter Number Of Terms::");
   scanf("%d",&n);
   textcolor(12);
   cprintf("\nPrime Numbers Are Follwing:\r\n\n");
   while(i<=n)
   {
      c=0;
      for(j=1;j<=i;j++)
      {
       if(i%j==0)
     c++;
      }
    if(c==2)
     printf("%28d\n",i);
    i++;
 }
 getch();
}
Output:

 
 
No comments:
Post a Comment