#include <stdio.h>

int main()
{
    int i, n;
  
    printf("Print all even numbers till: ");
    scanf("%d", &n);

    printf("Even numbers from 1 to %d are: \n", n);

    /*
     * Start loop counter from 1, increment it by 1,
     * will iterate till n
     */
    for(i=1; i<=n; i++)
    {
        /* Check even condition before printing */
        if(i%2 == 0)
        {
            printf("%d\n", i);
        }
    }

    return 0;
}

Embed on website

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