C program to print all even numbers from 1 to n - infinitynotes00

c program
C PROGRAM

 C program to print all even numbers from 1 to n - infinitynotes00


#include<stdio.h>
#include<conio.h>
void main()
{
    int n,i;
    clrscr();
    printf("Enter n \n");
    scanf("%d",&n);
    printf("Even number sequence is");
    for(i=2;i<n;i=i+2)
    {
        printf("\n%d\n",i);
    }
    getch();
}

OUTPUT:

Enter n
10
Even number sequence is
2
4
6
8
[Process completed (code 10) - press Enter]


No comments:

Post a Comment




Copyright Ⓒ 2022 | Mechpedia | All Right Reserved.