Search C Program | nimishsoft@gmail.com

Prime number using for loop

/* Prime number using for loop */

#include<stdio.h>
int main()
{
    int a,i,f;
    printf("Enter a number: ");
    scanf("%d",&a);
    f=0;
    for(i=2;i <= a/2;i++)
    {
        if(a%i == 0)
        {
            f=1;
            break;
         }
    }
    if(f==0)
        printf("Prime Number")
    else
        printf("Not Prime Number");
    return 0;
}

Related Post
Prime Number using while loop
http://cbasicprogram.blogspot.in/2012/03/prime-number-using-while-loop.html

12 comments:

  1. how to find prime no using odd loop

    ReplyDelete
    Replies
    1. Attention everyone, the file provided above is not working. I have been looking for the working file and finally found it.



      ✔️Click Here To Download http://gestyy.com/e0GAyS
      ✔️Click Here To Download

      ✔️Click Here To Download http://exe.io/XONVsO6l

      ✔️Click Here To Download


      ✔️Click Here To Download
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .

      .

      .
      .

      .

      .
      .
      .
      .

      Mn.
      ..

      .
      .
      .
      ..
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      ..
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .
      .cx
      .
      .
      .sdcccxxxcx

      Delete
  2. you forgot to use ';' in printf

    ReplyDelete
  3. this is a wrong program why i example it is infinitive time loop work

    ReplyDelete
  4. not working on 49,55.......

    ReplyDelete
  5. for loop should contain "a-2" instead of "a/2".

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete