Program to find all prime numbers between 100 and 200, requiring 6 prime numbers to be output per line.
code show as below:
#include<stdio.h>
#include <string.h>
#include <math.h>
int main()
{
int m;
int i;
int k;
int count=0;
for(m=100;m<200;m++)
{
k=sqrt(m);
for(i=2;i<=k;i++)
{
if(m%i==0)
{
break;
}
}
if(i>k)
{
printf("%d ",m);
count++;
if(count%6==0)
{
printf("\n");
}
}
}
printf("\n");
}
The algorithm of prime numbers has a similar problem in the column C language:
how to judge whether a number is a prime number or not. The
result of the above operation is shown in the figure:
Cai Cai's code, I hope it can help you!