# Prime number

This is a discussion on Prime number within the C Programming forums, part of the General Programming Boards category; b % a gives you the remainder of the division of b by a. Ex : 9 % 3 = ...

1. b % a gives you the remainder of the division of b by a.

Ex :
9 % 3 = 0
9 % 2 = 1
9 % 5 = 4
etc...

EDIT : How the heck did this get posted at the top ?

2. ## Prime number

Hi all here is code below i did to find a prime number as far as i m concerned it works fine .
Code:
```#include<stdio.h>
#include<conio.h>
main()
{
int a=1;
int b;
int count =0;
clrscr();
scanf("%d",&b);
//checks the programs
if ( b < 0 )
{
printf("\n\n\tEnter a postive number program ended.",b);
return 0;
}//the program will not be executed if the user has entered a negative number,
//start for the prime numbers check.
while (a < b)
{
if ( b % a == 0)//check if the given number has a remainder of the previous numbers.
{
/*Enable this printf is you want to check on which numbers
the the remainder is zero.
printf ("the remainder is zero on %d\n",a);
*/
count++;//a counter to dertmine how many times the given number has remainder zero.
}
/*
Enable this part of the program if you want to check on which numbers
the remainder is not zero.
else if ( b % a != 0)
{
printf("the raimder is not zero on %d\n",a);
}*/
a++;
}
//this part of the program uses the counter to print if the number has more then 2
//divisors on which the remainder is zero then it will print the results

if (count >= 2)
{
printf("\nThe number %d is not prime ",b);
}
else if ( count <= 2)
{
printf("\n the number %d is prime ",b);
}
//program ended

return 0;
}```
and anyone can explain me the correct use of "%"