Prime number program in c using do-while loop

Prime number program in c using do-while loop

 Prime number program in c using do-while loop:
#include<stdio.h>
int main()
{
    int i,j,k;
    printf("Enter a number: ");
    scanf("%d",&i);
    k=0;
    j=2;
    do
    {
        if(i%j == 0)
        {
            k=1;
            break;
        }
        j++;
    }
    while(j <= i/2);
    if(k==0)
        printf("The entered number is Prime Number");
    else
        printf("Entered number is Not Prime Number");
    return 0;

}
Output:
Enter a number: 7

The entered number is Prime Number.

See also: 

Share:

Our Services

Search This Blog

  • ()
Powered by Blogger.

TikTok Sign Up and Account Registration in detail

TikTok Sign Up and Account Registration  The steps to create an account on Tik Tok application for Android and ios. Download and introd...