Thursday, July 22, 2010

Function to check that no is prime or not ( GTU Sem I Program No : 30)

/*Write a fucntion prime which returns 1 is argument is prime no otherwise 0
  Program No   : 30 of GTU Practice Programs
  Developed by : Malhar Vora
  Developed on : 20/07/2010
  Email        : vbmade2000@gmail.com
  Web Site     : http://malhar2010.blogspot.com
****************************************************************************/


#include


short prime(int no)
{
    if(no % 2==0)
       return 0;
    else
       return 1;
}


void main()
{
   int no;
   printf("Enter a no :");
   scanf("%d",&no);
   if(prime(no)==1)
   {
      printf("\nNo is prime");
   }
   else
   {
      printf("\nNo is not prime");
   }

} 


1 comment:

  1. tech blog
    Today’s blogs offer everything from serious investigative journalism to silly photos, and they’re created by everyone from talented amateurs to staffers at some of the world’s largest media companies.

    ReplyDelete