Code for Program to input number is prime or not in C Programming
#include <stdio.h>
#include <conio.h>
int prime(int n);
void main()
{
int i,n;
clrscr();
printf("\n Enter The Number : ");
scanf("%d",&n);
i=prime(n);
if(i==1)
printf("\Given Number Is prime ");
else
printf("\n Given Number Is Not Prime ");
getch();
}
int prime(int n)
{
int i;
if(n<=2)
return 1;
elsefor(i=2;i<n;i++)
{
if(n%i==0)
return 0;
}
return 1;
}
/*
******
OUTPUT
******
Enter The Number : 4
Given Number Is Not Prime
*/