Skip to content

Commit 5ae41b0

Browse files
committed
prime numbers using function c-basics
1 parent 2bc184b commit 5ae41b0

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

primenosfun.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#include<stdio.h>
2+
void prime();
3+
void main()
4+
{
5+
int n;
6+
printf("Enter the number");
7+
scanf("%d",&n);
8+
prime(n);
9+
}
10+
11+
void prime(int a)
12+
{
13+
if (a==1)
14+
{
15+
printf("Neither prime nor composite");
16+
}
17+
else if(a==2||a==3||a==5||a==7)
18+
{
19+
printf("Prime");
20+
}
21+
else if(a%2==0||a%3==0||a%5==0||a%7==0)
22+
{
23+
printf("NOT PRIME");
24+
}
25+
else
26+
{
27+
printf("PRIME");
28+
}
29+
}

0 commit comments

Comments
 (0)