4. Write a C program that checks if a number is prime or not.
Sat Jul 22 2023 12:36:24 GMT+0000 (Coordinated Universal Time)
Saved by
@Codes
// Online C compiler to run C program online
#include <stdio.h>
#include <stdbool.h>
int main() {
int n =10;
bool flag = true;
for(int i = 2; i < 5; i++){
if(n%2==0){
flag = false;
}
}
if(flag==true){
printf("This number is a prime number: %d", n);
}
else if(flag==false){
printf("This number is not a prime number: %d", n);
}
return 0;
}
content_copyCOPY
Comments