Tuesday, 31 December 2013

PROGRAM TO CHECK WHETHER GIVEN NUMBER IS PRIME OR NOT....!!!!

#include<stdio.h>
int main()
{
 int number;
 int count=0;
 printf("Enter number to check if it is prime or not:");
scanf("%d",&number);
for(int a=1;a<=number;a++)
{
  if(number%a==0)
  {
  count++;
  }
}
    if(count==2)
    {
    printf("\nNUMBER IS PRIME");
    }
    else
    {
    printf("\nNUMBER IS NOT PRIME");
    }
return 0;
}

EXPECTED OUTPUT;
















No comments:

Post a Comment