Friday, 21 July 2017

to find given number is prime or not

#include<stdio.h>  
#include<conio.h>  
void main()  
{  
int n,i,m=0,flag=0;  
clrscr();  
printf(" number to find prime:");  
scanf("%d",&n);  
m=n/2;  
for(i=2;i<=m;i++)  
{  
if(n%i==0)  
{  
printf("Number is not prime");  
flag=1;  
break;  
}  
}  
if(flag==0)  
printf("Number is prime");  
getch();  





OUTPUT:

Enter
the number to find prime:76
Number
is not prime
Enter
the number to check prime:17
Number
is prime

No comments:

Post a Comment

if else if program

#include<stdio.h>    #include<conio.h>    void  main(){   int  number=0;   clrscr();      printf( "enter a number:" )...