Code Scrappers


Even & Odd C - Program


                    #include<stdio.h>
                    #include<stdlib.h>

                    void main()
                    {
                        int i, num;

                        printf("enter the value of n\n");

                        scanf("%d",&num);

                        printf("even numbers are\n");

                        for(i=1;i<=num;i++)
                        {
                            if(i%2==0)

                            printf("%d\n",i);

                        }

                        printf("odd numbers are\n");

                        for(i=1;i<=num;i++)
                        {
                            if(i%2!=0)

                            printf("%d\n",i);

                        }

                    }

                



Output

            enter the value of n
            10
            even numbers are
            2
            4
            6
            8
            10
            odd numbers are
            1
            3
            5
            7
            9