WAP to display all the odd number less than 10
Answers
Answered by
9
Answer:
//Program to display all odd numbers less than 10
//Done in JAVA
package Programmer;
public class OddPrint{
public static void main (String ar []){
System.out.println("Odd numbers less than 10 are as follows:-");
for(int I=1;I<10;I+=2;)
System.out.println(I);
}
}
_
Variable Description:-
- I:- loop variable
_
How to print the odd numbers?
- It's easy, Just run a loop from 1 to (10-1)
- each iteration print the loop value and update the loop value with +2
- Close the loop
- tan-tada! You are done!
_
For output, see the attachment
Attachments:
Similar questions