/*Serial No.78 [swami47.cpp]*/
#include<stdio.h>
#include<conio.h>
void prime(int n)
{
int a=2;
if(n==a)
printf("prime number");
while(a<n)
{
while(n%a!=0)
{
a++;
}
if(n/a==1)
{
printf("prime number");
}
else
{
printf("not prime");
break;
}
}
}
void main()
{
int num;
printf("Enter number:=");
scanf("%d",&num);
prime(num);
getch();
}
#include<stdio.h>
#include<conio.h>
void prime(int n)
{
int a=2;
if(n==a)
printf("prime number");
while(a<n)
{
while(n%a!=0)
{
a++;
}
if(n/a==1)
{
printf("prime number");
}
else
{
printf("not prime");
break;
}
}
}
void main()
{
int num;
printf("Enter number:=");
scanf("%d",&num);
prime(num);
getch();
}
No comments:
Post a Comment
If you have any doubt, feel free to ask...