Check Wheter the No Is Preime or Not

  • #include<stdio.h>
     
    main()
    {
       int n, c = 2;
     
       printf("Enter a number to check if it is prime\n");
       scanf("%d",&n);
     
       for ( c = 2 ; c <= n - 1 ; c++ )
       {
          if ( n%c == 0 )
          {
             printf("%d is not prime.\n", n);
         break;
          }
       }
       if ( c == n )
          printf("%d is prime.\n", n);
     
       return 0;
    }

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week

Optimum Creative