prime number program c language jalandhar

Check Whether a Prime number in C Language or Not

In This Post, we will describe how to check the entered number is prime or not. Prime number in c language is the common program in c language. Prime numbers are the numbers that have only two factors, that are, 1 and the number itself. Digital Jalandhar is the Best Institute in Jalandhar. we are offering C language Coaching.

For example 1,2,3,5,7,11,15,17,19…!!!! are the Prime numbers

Algo Steps Prime number in C Language

  • Enter the number from the keyboard.prime number
  • dived the entered number from 1 to till entered number.
  • If the number is divisible only 2 times, then the entered number is a prime number else, not a prime number.

Let’s see the prime number in C Language. In this c program, we will get input from the user and check whether the number is prime or not.

 

//– prime number that number whose divide only two number

//==================like 1,3,5,7 etc…………………
#include<stdio.h>
#include<conio.h>
void main()
{

int n,i=2,c=0;
clrscr();
lable:
printf(” ENTER THE NUMBER ::”);
scanf(“%d”,&n);
if(n==1)
{
printf(” ONE IS ALSO A PRIME NO.SO AGIN NEW NO.”);
goto lable;
}
while(i<=n)
{
if(n%i==0)
{
c++;
}
i++;
}
if(c==1)
printf(” the number is prime “);
else
printf(” not prime “);
getch();
}

Leave a Comment

Your email address will not be published.