write a program in Java to display first ten odd numbers entered by the user.
Answers
Answered by
1
Answer:
Steps:-
- import java. util. *;
- public static void main(String[] args) {
- Scanner sc = new Scanner(System. in);
- System. out. println("Enter a no");
- int n = sc. nextInt();
- System. out. println("First "+n+" ODD nos");
- for(i=1;i<=2*n;i++)
- if(i%2 == 0)
C ode:-
import java.util.*;
class oddNos {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a no");
int n = sc.nextInt();
int i;
System.out.println("First "+n+" ODD nos");
for(i=1;i<=2*n;i++)
{
if(i%2 == 0)
continue;
else
System.out.println(i);
}
}
}
Similar questions