Select Menu

Slider

Software's

Transportation

Cement Testing

Inventor

Manual Survey Practical

Quantity Surveying

Videos

» » Check for Prime or not a Prime Number (C-Programming)
«
Next
Newer Post
»
Previous
Older Post


#include<stdio.h>
#include<conio.h>
void main()
{
int n,i=2,div=0;
clrscr();
printf("\nEnter a value");
scanf("%d",&n);
while(i<n) //2<8
{
if(n%i==0) //8%2==0
{
div++;
}
i++;

}
if(div==0)
printf("\nprime number");
else
printf("\nnot a prime number");
getch();
}

«
Next
Newer Post
»
Previous
Older Post

No comments

Leave a Reply

Post Your Comments