write a program to print prime number between 1 to 50.

#include<stdio.h>
#include<conio.h>
int main()
{
int i,j,ans;
printf("Prime Number between 1 to 50\n");
for(j=1;j<=50;j++)
{
ans=0;
for(i=2;i<=j/2; i++)
{
if(j%i==0)
{
ans++;
}
}
if(ans==0&&j!=1)
{
printf("%d\n",j);
}
}
return 0;
}

Comments

Popular posts from this blog

write a program for insertion sort with example.