Showing posts with label Prime Numbers. Show all posts
Showing posts with label Prime Numbers. Show all posts

Write a Program to print Prime Numbers between 1 to 100

#include <stdio.h>
#include <conio.h>
void main()
{
  int a[100],i,j=2;
  clrscr();
  for(i=0;i<100;i++)
   a[i]=i+1;
printf("Prime Number between 1 to 100 \n");
  for(i=0;i<100;i++)
   {
    for(j=2;a[i]>j;j++)
      {
     if(a[i]%j==0)
     break;
      }
     if(a[i]==j || a[i]==1)
       printf("%d\t",a[i]);
    }
getch();
}

Related Post

Array:
String functions:
General (Loops-for/while)
Write a Program to print reverse of a given number Write a Program to print Product of Digits (eg. 212=2*1*2=4) of a given number Write a C++ Program to Convert Binary into Decimal Number