#include<stdio.h>
#include<conio.h>
int isprime(int n)
{
int boolean,i;
for(i=2;i<n;i++)
{
if(n%i!=0)
boolean=1;
else
{
boolean=0;
break;
}
}
return boolean;
}
void main()
{
int number;
clrscr();
printf("\nEnter the number : ");
scanf("%d",&number);
if(isprime(number))
printf("\n\tThe number is prime");
else
printf("\n\tThe number is not prime");
getch();
}
Algoirthm
isprime(n)
step1: start
step2: intilize i<-2 br="">step3: check whether i else go to step 11
step4: if n%i!=0,then go to step 5
else go to step 6
step5: boolean=1
step6: boolean=2
step7: break
step8: i=i+1
step9: go to step 3
step10: return boolean
step11: stop
main()
step1: start
step2: read number
step3: if isprime(number)=1,then go to 4
else go to step 5
step4: print prime
step5: print not prime
step6: stop -2>
#include<conio.h>
int isprime(int n)
{
int boolean,i;
for(i=2;i<n;i++)
{
if(n%i!=0)
boolean=1;
else
{
boolean=0;
break;
}
}
return boolean;
}
void main()
{
int number;
clrscr();
printf("\nEnter the number : ");
scanf("%d",&number);
if(isprime(number))
printf("\n\tThe number is prime");
else
printf("\n\tThe number is not prime");
getch();
}
isprime(n)
step1: start
step2: intilize i<-2 br="">step3: check whether i
step4: if n%i!=0,then go to step 5
else go to step 6
step5: boolean=1
step6: boolean=2
step7: break
step8: i=i+1
step9: go to step 3
step10: return boolean
step11: stop
main()
step1: start
step2: read number
step3: if isprime(number)=1,then go to 4
else go to step 5
step4: print prime
step5: print not prime
step6: stop