/* 2 program of prime number and check from 2and so on */
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
clrscr();
printf("Enter a number :");
scanf("%d",&n);
i=2;
while(i<=n-1)
{
if(n%i==0)
{
printf("Not a prime number ");
break;
}
i++;
}
if(i==n)
printf("prime number");
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
clrscr();
printf("Enter a number :");
scanf("%d",&n);
i=2;
while(i<=n-1)
{
if(n%i==0)
{
printf("Not a prime number ");
break;
}
i++;
}
if(i==n)
printf("prime number");
getch();
}
No comments:
Post a Comment