Skip to main content

Check prime

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int i,num;
printf("Enter the number:");
scanf("%d",&num);
int countfactor=0;
for(i=1;i<=num;i++)
{
if (num%i==0)
countfactor++;
}
if(countfactor==2)
printf("Entered Number is a prime number");
else
printf("Entered Number is not a prime number");

getch();
}

Comments

Popular posts from this blog

Reversing digits of a number

#include<stdio.h> #include<conio.h> void main() { clrscr(); int ,num,rev=0,rem; printf("Enter the number:"); scanf("%d",&num); while(num!=0) { rem=num%10; rev=rev*10+rem; num=num/10; } printf("Reverse of given Number is:%d",rev); getch(); }