Pages

Saturday, July 2, 2016

C program to print Even number series 2 4 6 8 ... N.

C Program to print Even number series 2 4 6 8 ... N for the given value of N.

For example, if N=10, output should be
2 4 6 8 10

Program Code

#include<stdio.h>
int main()
{
  int i, N;
  printf("Enter N:");
  scanf("%d", &N);

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

Program Code

Enter N:10
2 4 6 8 10




No comments:

Post a Comment