Have a Read!

Hi Everyone.
The idea for this page is to provide new c users simple c tutorials to learn how to develop the logic and more importantly correct way to write syntax.
ENJOY !!!

Thursday, January 27, 2011

C PROGRAM FOR PRIME NUMBER way1

#include <stdio.h>
int main()
{
int x,y,z,a=0;
printf("enter the number: ");
scanf("%d",&x);
for (y=2;y<x;y++)
      { if (x%y==0)
            {a=y;}   
    }// loop end
if(a==0)
{printf("Number is Prime\n");}
else
{printf("Number is not Prime\n");}
return 0;
}

No comments:

Post a Comment

Related Posts with Thumbnails