this program will print all the Even numbers under the number entered by user when this program is executed.In this program we have b=0 as a first Even number.then after printing first number it will increase the value of 'b' by 2 and new value will be 2 which is also a Even number and like this, program will run till condition becomes false in for loop.
Program:
#include<stdio.h>
#include<conio.h>
main()
{
int a,b;
clrscr();
printf("Enter Number: ");
scanf("%d",&b);
printf("\n");
for(a=0;a<=b;a+=2)
{
printf("%d,",a);
}
getch();
}
Program:
#include<stdio.h>
#include<conio.h>
main()
{
int a,b;
clrscr();
printf("Enter Number: ");
scanf("%d",&b);
printf("\n");
for(a=0;a<=b;a+=2)
{
printf("%d,",a);
}
getch();
}