/* This is HW3 is check for prime numbers and even
Creating the code and free of syntax and grammatical errors.
Author: Ekwegbalum Unachukwu
Star ID: do2170dt
Date April 2nd, 2024.
*/

#include <stdio.h>

int main(void) {
    int num_EU, check_EU;

    printf("Prime numbers up to 50: ");
    for (num_EU = 2; num_EU <= 50; ++num_EU) {
        int isPrime_EU = 1; // Assume prime initially
        for (check_EU = 2; check_EU * check_EU <= num_EU; ++check_EU) {
            if (num_EU % check_EU == 0) {
                isPrime_EU = 0; // Not prime
                break;
            }
        }
        if (isPrime_EU) {
            printf("%i ", num_EU);
        }
    }

    printf("\nEven numbers up to 50: ");
    for (num_EU = 2; num_EU <= 50; ++num_EU) {
        if (num_EU % 2 == 0) {
            printf("%i ", num_EU);
        }
    }

    printf("\n");
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: