Saturday, August 11, 2012

Program to find Prime number from 0 to given range C language



#include<conio.h>
#include<stdio.h>
void main()
{
int n,i,k;
clrscr();
printf("\n Enter any number");
scanf("%d",&n);
i=1;
k=0;
while(i<=n)
{
if(n%i==0)
{
k++;
if(k>2)
{
printf("\n Enterd number %d is not prime number",n);
break;
}
}
i++;
}
if(k<=2)
{
printf("\n Enterd number %d is prime number",n);
}
getch();
}

No comments:

Post a Comment

DC motor control with Pulse Width Modulation Part 1

DC Motor intro DC motor is a device which converts electrical energy into kinetic energy. It converts the DC power into movement. The typica...