Write a program to print the entire prime no between 1 and 300.
Program in C language
#include<stdio.h>
#include<conio.h>
int IsPrime(int num)
{
int i,b=1;
for(i=2;i<num;i++)
{
if(num%i==0)
{
b=0;
break;
}
}
return b;
}
void main()
{
int i;
for(i=2;i<=100;i++)
{
if(IsPrime(i))
{
printf("%d\n",i);
}
}
}
No comments:
Post a Comment