C program to print the even numbers
codeaft.c
#include <stdio.h>
int main()
{
    int i;
    for (i = 0; i <= 10; i++)
    {
        printf("%d\n", i);
        i++;
    }
}
Output
codeaft@codeaft:~$ gcc codeaft.c
codeaft@codeaft:~$ ./a.out 0 2 4 6 8 10 codeaft@codeaft:~$
C program to print the odd numbers
codeaft.c
#include <stdio.h>
int main()
{
    int i;
    for (i = 1; i <= 10; i++)
    {
        printf("%d\n", i);
        i++;
    }
}
Output
codeaft@codeaft:~$ gcc codeaft.c
codeaft@codeaft:~$ ./a.out 1 3 5 7 9 codeaft@codeaft:~$
Comments and Reactions