Tuesday, October 11, 2011

Even numbers being looped(iteraive)

Write a program that asks the user to enter a number n and display the first even numbers. Example: if n=5, the first 5 even numbers are 2, 4, 6, 8 and 10. 


(Solution)

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

int main( )
{
   int ONE, TWO;
   printf("Enter Number: ");
   scanf("%d",&TWO);
   for (ONE=0; ONE<=TWO; ONE+=2)
     {
          printf ("%d\n",ONE);
      }

getch( );
return 0;
}

0 comments:

Post a Comment