C Program: Print Prime Numbers Under 100
This is a program written in the C language that prints all prime numbers below 100.
#include <stdio.h>
int isPrime(int num) {
if (num < 2) {
return 0;
}
for (int i = 2; i * i <= num; i++) {
if (num % i == 0) {
return 0;
}
}
return 1;
}
int main() {
printf("Prime numbers between 1 and 100 are: \n");
for (int i = 2; i <= 100; i++) {
if (isPrime(i)) {
printf("%d ", i);
}
}
return 0;
}
This program first defines a function called isPrime() to check if a number is prime. Then, in the main function, it iterates through all integers from 2 to 100, and if a number is prime, it will be output. The program will eventually output all prime numbers within 100.