Brijmohan lal Sahu - Facebook
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Saturday, November 8, 2014

Program to print all prime numbers between a given range of numbers in C.

Prime Number


Code Box
---------------------------------------------

/* Program to print all prime numbers between a given range of numbers */

#include<stdio.h>
#include<conio.h>
void main()
{
int start,end,i,j,c;
clrscr();

printf("\nEnter Start of range:");
scanf("%d",&start);

printf("\nEnter End of range :");
scanf("%d",&end);

printf("\n\nPrime Numbers in range :");
for(i=start;i<=end;i++)
{c=0;
for(j=2;j<start;j++)
{
if(i%j==0)
{
c=1;
}
}
if(c==0)
{
printf(" %d",i);
}
}

getch();
}


No comments: