Checking Entered Number .. Prime or Not


#include<stdio.h>  
#include<conio.h>
int main()
{    
int n,i,m=0,flag=0
//n variable is used to store the value of entered number
//varible i for loop
//variable m for storing the result
//variable flag for used for if statement  
printf("Enter to check the number :");    
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");
}     
return 0



Output:-
Enter to check the number :2 Number is prime

Attached .c File :- πŸ‘‡πŸ‘‡

Comments

Post a Comment

Popular posts from this blog

Check whether the no entered is Palindrome or not

Calculate Factorial of a given no with help of Recursion

Find max. and min. element in the integer array