Program : Write a c program to generate all prime numbers between 1 to n.
Crated By : JABIR PATHAN
#include<stdio.h>
#include<conio.h>
void main()
{
int no,i;
clrscr();
printf("Enter any number or Range==>");
scanf("%d",&no);
for(i=1;i<=no;i++)
{
if(i==1||i==2||i==3||i==5||i==7)
{
printf("\t%d",i);
}
else
if(i%2>0&&i%3>0&&i%5>0&&i%7>0)
{
printf("\t%d",i);
}
}
getch();
}
No comments:
Post a Comment