Saturday, 22 August 2015

Write a C Program To Print Series 2,4,6,8,10 Using For Loop

#include<stdio.h>
#include<conio.h>

int main()
{
            int i,n;  // declare two integer type variables
            clrscr();  // clears the output window

            printf("\n Enter the number : ");
            scanf("%d",&n);  // input the value of n

            printf(“\n”);   // will break the line on output window

            for(i=2;i<=n;i++)
            {
                        if(i%2==0)
                        {          
                                    printf(" %d ",i);
                        }
            }

            getch();

            return 0;

}

No comments:

Post a Comment