Write a c program whether a number is prime or not,Write a c program prime or not,Write a c program given number is prime or not,write a c program to check prime number,write a c program prime number
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,status=1;
clrscr();
printf("Enter the number: ");
scanf("%d",&n);
for(i=2;i<=n/2;i++)
{
if(n%i==0)
{
status=0;
printf("It is not a prime number");
break;
}
}
if(status)
printf("It is a prime number");
getch();
}
Output:
run 1:
Enter the number: 6
It is not a prime number
run 2:
Enter the number: 7
It is a prime number
No comments: