C Program To check if a number is Prime Number or not

C
Loading...

C Program To check if a number is Prime Number or not in Hindi – C Programming Me Ham Prime Number Program Ko Create Karne Wale Hai, Jo Ye Program If And Loop Se Banayenge Or Isme Ham Find Karenge Ki Prime Number Hai Ya Nhi |

Yadi Aapne  HTML Full Course  And CSS Full Course And Python Full Course And PHP Full Course Nhi Read Kiya Hai To Aap Vah Bhi Read Kar Sakte Hai |

C Program To check if a number is Prime Number or not

What is Prime No: – Prime No Wo Hota hai jo ( N%2== 1 ) Aane par bach ta hai, Yaha Par N Number Hai |

Isse Or Accha Samanjh Ne Ke Liye Ham Iske Example Ko Dekh Te Hai |

prime no program in c

Generate Prime Numbers in C With Example

Syntax Prime No :-

if (n%2==0)
{ 
   Not Prime
}
else 
 {
   Prime No
 }

Example :-

#include <stdio.h>
#include <conio.h>
int main()
{
	int n;
        printf("Enter The Number To Find Prime Or Not :");
        scanf("%d",&n);
    
        if(n%2==0)
        {
            printf("Number Is Not Prime %d",n);
        }
        else
        {
           printf("Number is Prime %d",n);
        }
    
getch();
}

Output:

Enter The Number To Find Prime Or Not : 10
Number Is Not Prime 10


Enter The Number To Find Prime Or Not : 11
Number is Prime 11

Upper Diye Gye Output ko dekh kar aap Prime Program ko samanjh sakte hai |

Using For Loop Find Prime No with example

Example :-

#include<stdio.h>
#include<conio.h>
int main()
{
	 int n,i,flag=1;
         printf("Enter The Number To Find Prime No Or Not :");
         scanf("%d",&n);
        
         for(i=1;i<n/2;i++)
           {
               if((n%i)==0)
                     {
                        flag=0;
                        break;
                      }
                else
                       {
                         continue;
                       }
           }

          if(flag==1)
                      {
                           printf("Number is Prime");
                       }
          else
                     {
                           printf("Number is Not Prime");
                     }
getch();
}

Output:

Enter The Number To Find Prime No Or Not : 10
Number is Not Prime


Enter The Number To Find Prime No Or Not : 11
Number is Prime

More Practice Program:

Friends Mujhe Umeed Hai Ki Aapko C Language program To check if a number is Prime Number or not In Hindi Ke Bare Mai 100% Jankari Ho Gayi Hogi | Agar Aapko Learn Karne Main Dikkat Aa Rahi Hai To Aap Mere Se Contact Kar Sakte Hai |

MasterPrograming Apps

Leave a Reply

Your email address will not be published.