Genarate the series of first 10 odd number (while loop)

0
Output

Explanation of the Odd Number Printing Program

This C program prints all odd numbers starting from 1 up to the number entered by the user. It uses a while loop to repeatedly increase the value of fno by 2, ensuring only odd numbers are printed.

The program begins with the first odd number (fno = 1) and continues printing the next odd numbers until the value exceeds the last number entered by the user.

What the Program Does

  • Starts with the first odd number: 1.
  • Asks the user to enter the last number.
  • Prints odd numbers as long as fno ≤ lno.
  • Increases fno by 2 each time, so it always remains odd.
  • Uses clrscr() to clear the screen (Turbo C++) and getch() to pause the output.

Example Input

Enter the last number: 15

Example Output

1 3 5 7 9 11 13 15

Summary:
This program prints a sequence of odd numbers from 1 to the user-defined limit. It demonstrates the use of loops, increment operators, and conditional checking in C programming.

Tags

Post a Comment

0Comments

Post a Comment (0)