Advertisement

Prime or not prime, using loop::


#include<conio.h>
#include<stdio.h>
void main()
{clrscr();
int i,n,a,b;
printf("enter a number=");
scanf("%d",&n);
a=0;
for(i=2;i<=n;i++)
{b=n%2;
if(b==0)
{a=1;}
       }
if(a==1)
{printf("not prime");}
else
{printf("prime number");}
getch();}

No comments:

Post a Comment

Please comment bellow. Share your knowledge