{I am going write the c program but before you need a c compiler(software).there are a lot of compilers(softwares). like Code::Blocks,dev c++ . Download dev c++ its free and install it in your computer.open dev c++ go to file-->new-->source file.}
#include<stdio.h>
#include<conio.h>
main()
{
int n,i,f=0;
printf("enter a number");
scanf("%d",&n);
for(i=2;i<n/2;i++)
{
if(n%i==f)
f++;
}
if(f==0)
printf("number is prime");
else
printf("not prime");
getch();
}
For beginners
{After typing this program go to execute-->compile & run-->a window will pop-up-->give file name:(anything u like)-->save as type: c source files-->click save.}
IS IT HELPFIL? comment
Yes, thank you for this blog :D Can I ask something sir ?
ReplyDeletePrime number program in C++
ReplyDeleteprime number is only divisible by 1 and itself,
we can easily write prime number program in c++, just check number is not divisible by any other numbers except 1 and number itself.
A Prime number is a natural number greater than 1 that is only divisible by either 1 or itself. All numbers other than prime numbers are known as composite numbers.
ReplyDeleteC program to check prime number.