SET A
1. Write a program to display all prime numbers between x and y.
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y,i,flag,j;
clrscr();
printf("\nEnter two Numbers:");
scanf("%d%d",&x,&y);
printf("\nPrime numbers between %d and %d is ",x,y);
for(i=x;i<y;i++)
{
flag=0;
for(j=2;j<i;j++)
{
if(i%j==0)
flag=1;
}
if(flag==0)
printf("\n%d",i);
}
getch();
}
OUTPUT:
Enter two Numbers:1
20
Prime numbers between 1 and 20 is
1
2
3
5
7
11
13
17
19