C program to print EVEN numbers from 1 to N using while loop:Hi,You know about Even numbers.We make program of series of even numbers using for loop statement in C .in this program is that the initialize is outside the for loop statement in C.C program to print all even numbers between 1 to n using while loop.
C Program To Display All Even Or Odd Number From 1 To N
Source Code
#include <iostream>
int main()
{
int counter=0;
counter = 2;
printf("\tInitializer Outside the For Statement in C");
printf("\n\n");
for( ; counter <=40; counter = counter +2)
{
printf(" %d ",counter);
}
printf("\n\n");
printf("\t End of Program ");
printf("\n\n");
}
Output of Code
Enter the value of N: 10 Even Numbers from 1 to 10: 2 4 6 8 10 Enter the value of N: 100 Even Numbers from 1 to 100: 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100
Even numbers between 1 to 100 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100
Happy coding 😉