Write a program to print the prime numbers from 1-100

//this is a program to print the prime numbers from 1-100
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,flag=0;

printf("\n\nPrinting the Prime numbers From 1-100\n\n");

for(i=1;i<=100;i++)
{
for(j=2;j<i;j++)
{
flag=0;
if(i%j==0)
{
flag=1;
break;
}
}

if (flag==0)
printf(" %d ",i);
}
getch();
}

Previous
Next Post »