C program to determine a number is prime or not.
#include<stdio.h>
#include<conio.h>
void main( )
{
int n, i , s=1;
clrscr( );
printf("Enter any number ");
scanf("%d",&n);
i=2;
while(i<=n/2 && s==1 )
{
if( n%i==0 )
{
s=0;
}
else
{
i=i+1;
}
if( s==1 )
{
printf("Number is Prime Number ");
}
else
{
printf("Number is Not Prime Number ");
}
getch( );
}
#include<stdio.h>
#include<conio.h>
void main( )
{
int n, i , s=1;
clrscr( );
printf("Enter any number ");
scanf("%d",&n);
i=2;
while(i<=n/2 && s==1 )
{
if( n%i==0 )
{
s=0;
}
else
{
i=i+1;
}
if( s==1 )
{
printf("Number is Prime Number ");
}
else
{
printf("Number is Not Prime Number ");
}
getch( );
}
0 Comments