Skip to main content

C Program Check Out Weather The No is Prime Or Not

Check Out Weather The No is Prime Or Not





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






Comments

Popular posts from this blog

C++ Program Finding The Absolute Value

#include<iostream> using namespace std; int main() { cout<<" enter any number"; cin>>num; if(num>0) { cout<<"The absolute value of number is:"<< num; } else { cout<<"The absolute value of number is :"<< -(num); } return 0; } OUTPUT Enter Any number: 2 The absolute value of number is 2