Follow This Blog For more... 😊

C program to accept number and print if it is prime number or not.| Using C language| C Program series 50|

👨‍💻C Program to accept number and 
print if it is a prime number or not.

Code :

    /*
    C program to accept number and print if it is prime number or not.
   
    */
    #include<stdio.h>
    main()
    {
        int i,n,flag=0;
       
        printf("Enter the number:");
        scanf("%d",&n);
       
        for(i=2;i<n;i++)
        {
            if(n%i==0)
            {
                flag=1;
                break;
            }
            else
            {
                flag=0;
            }
        }
       
        if(flag==0 && n!=1)
        {
            printf("%d is Prime number.",n);
        }
        else
        {
            printf("%d is Prime not number.",n);
        }
    }

The output of Code:






👉Click for more C Program series Questions.[Questions list]

Comments

Popular Posts