Code: int prime (int N);
int main(int argc, char *argv[]) {
int N;
printf("Enter a number: "); scanf("%d", &N);
prime(N);
return 0;
}
int prime (int N) {
if (N % 2 == 0) {
printf("It is a not prime number");
return 1;
}
else {
printf("It is a prime number");
return -1;
}
}
Bài 2:
code:
int isPrime (int N[]);
int main(int argc, char *argv[]) {
int N[5];
int i;
for (i = 0; i < 5; i++) {
printf("Enter 5 number: "); scanf("%d", &N[i]);
}
isPrime(N);
return 0;
}
int isPrime (int N[]) {
int i;
for (i = 0; i < 5; i++){
printf("\n[%d] - %d",i + 1, N[i]);
}
return 0;
}
No comments:
Post a Comment