Example 3:prime number example:-
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
y=1;
z=2;
printf("enter a num:");
scanf("%d",&x);
while (z <= x/2)
{
if(x%z==0);
y=0;
z=z+1;
}
if (y==0)
printf("it is not a prime number");
else
printf("prime");
getch();
}
#include<stdio.h>
#include<conio.h>
int main()
{
int x,y,z;
y=1;
z=2;
printf("enter a num:");
scanf("%d",&x);
while (z <= x/2)
{
if(x%z==0);
y=0;
z=z+1;
}
if (y==0)
printf("it is not a prime number");
else
printf("prime");
getch();
}
No comments:
Post a Comment