tags: C language questions c++
Write a function isprime,
function is to determine if a number is a prime number, if it returns 1, otherwise returns 0.
Call in the main function, the function of the main function implementation is:
Outputs all the numbers between 100-300, and 6 data is displayed per line.
#include<stdio.h>
#include<math.h>
int IsPrime(int x) // Function, determine if a number is the number of prime, if it is returned 1, otherwise returns 0
{
int i,k;
k=sqrt(x);
for(i=2; i<=k; i++)
if(x%i==0) return 0;
return 1; // Notice to write into Else Return 1; it is wrong! ! Error !!
}
int main()
{
int y, j=0;
for(y=101; y<=300; y+=2)
if( IsPrime(y)) // if( IsPrime(y)==1)
{
printf("%d ", y);
j++;
if(j%6==0) printf("\n");
}
return 0;
}
c program: write a function for judging prime numbers, enter ten integers in the main function, and output prime number information! //Idea: Write a program, in which a custom function is used to dete...
[C language] Write a function to judge prime numbers, input an integer in the main function, and output a message about whether it is a prime number....
In addition to the special case of n<=1, the variable m is also used in the program. On the one hand, it avoids repetitive calculations of sqrt(a) each time. On the other hand, it also avoids float...
What does int isPrime(int n) mean in c language isPrimeIt is a custom function that passes in an integer n to determine whether it is a prime number. If it returns 1, otherwise it returns 0. #include&...
Title: / * Count the number of words in a line of strings, And return as a function value. The string is entered in the main function. Statify all words consisting of lowercase letters, Several spaces...
Write a function to distinguish prime numbers, input an integer in the main function, and output information about whether it is a prime number. #include <stdio.h> int sushu(int m) { int i,n=0; ...