To find whether a number is prime or not

#include<stdio.h>
#include<conio.h>
main()
{
   int i,number,remainder,interval;
   clrscr();
 /*program to test the prime property of a given number*/
 printf("type in the number to be tested\n");
 scanf("%d",&number);
 interval=number/2;
 for(i=2; i<=interval; ++i)
    {
    remainder=number%i;
    if(remainder==0)
    break;
    }
  if(remainder!=0)
    printf("given number %d is a PRIME NUMBER\n",number);
  else
    printf("given number %d is not a PRIME NUMBER\n",number);
  }


OUTPUT

type in the number to be tested
43
given number 43 is a PRIME NUMBER

Comments

Popular posts from this blog

New Regime Income Tax Calculator 2025-2026

Expense Tracker

Percentage Calculator