For this we have to know what is prime number.
Prime number is the number which is divisible by 1 and the number itself. Lets take an example. For example 2 is prime number and 4 is not prime number or it is composite number.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<conio.h> | |
int main() | |
{ | |
int num,i; | |
printf("enter any number"); | |
scanf("%d",&num); | |
i=2; | |
while(i<num) | |
{ | |
if (num%i==0) | |
break; | |
i++; | |
} | |
if (i==num) | |
{ | |
printf("the number is prime"); | |
} | |
else | |
printf("the number is not prime"); | |
} | |
0 comments :
Post a Comment