Program to display prime numbers between 1 to 100

//Program to display prime numbers between 1 to 100
#include<stdio.h>
#include<conio.h>
int main()
{
  int n,j;
  clrscr();
  printf("Prime numbers between 1 to 100\n");
  for(n=3;n<=100;n++)
  {
    for(j=2;j<=100;j++)
    {
     if(n%j==0)
     break;
    }
    if(j==n)
    printf("%4d",n);
  }
  getch();
  return 0;
}


To Run this Program Copy it in text editor and save as .c
Then double click on it and then it will get opened in your compiler.
Click on run.

9 comments:

  1. It won't give an output as they haven't printed it in the code
    They should write something like
    printf("Number is prime\n");

    ReplyDelete
  2. It won't give an output as they haven't printed it in the code
    They should write something like
    printf("Number is prime\n");

    ReplyDelete
  3. for(n=2;n<=100;n++) would also display 2.

    ReplyDelete
  4. in printf(%4d,n) why 4 is there in between percent and d

    ReplyDelete
  5. in printf(%4d,n) why 4 is there in between percent and d

    ReplyDelete
    Replies
    1. To suppress the result within for digits....u can just give ℅d too

      Delete