Explanation of the Even Number Printing Program
This C program prints all even numbers starting from 2 up to the number entered by the user. It uses a while loop and simple arithmetic to continuously add 2 and display each even number.
The program begins with the first even number (fno = 2) and repeatedly prints the next even number by increasing the value of fno by 2 each time. The loop stops when fno becomes greater than the number entered by the user.
What the Program Does
- Starts with the first even number: 2.
- Asks the user to enter the last number.
- Checks whether the current even number is less than or equal to the last number.
- Prints every even number within the range.
- Increases the number by 2 in each loop iteration.
- Uses clrscr() and getch() (Turbo C++ features) to clear the screen and pause output.
Example Input
Enter the last number: 12
Example Output
2 4 6 8 10 12
Summary:
This program prints a sequence of even numbers starting from 2 up to the user’s chosen limit.
It demonstrates the use of while loops, conditional checking, and increment logic in C programming.
