This is a basic program in c which checks whether the number is prime number or composite number.
PROGRAM :
OUTPUT:
PROGRAM :
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a, b;
printf("Enter a number to check Prime or Composite \t");
scanf("%d",&b);
if (b == 0 || b ==1)
printf("%d is neither Prime nor Composite",b);
for ( a = 2 ; a <= b-1 ; a++ )
{
if ( b%a == 0 )
{
printf("%d is Composite number\n", b);
break;
}
}
if ( b == a )
printf("%d is Prime number \n", b);
return 0;
}
OUTPUT:
| C - Prime or Composite |