Friday, 17 August 2012

c program for check prime number using for loop

For beginners
{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


3 comments:

  1. Yes, thank you for this blog :D Can I ask something sir ?

    ReplyDelete
  2. Prime number program in C++

    prime 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.

    ReplyDelete
  3. 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.
    C program to check prime number.

    ReplyDelete