write a program in Java to print first 10 natural numbers using 'for' loop with correct syntax.
Answers
Answered by
1
import java.util.Scanner ;
class Natural_no
{
void main ()
{
int n,i;
Scanner kb =newScanner(System.in);
System.out.println ("Enter the value for n:");
n=kb.nextInt ();
for (i=1;i <=n;i++)
}
System.out.println (i);
}
}
}
Output : Enter the value for n : 10
1
2
3
4
5
6
7
8
9
10
Answered by
0
Answer:
class num
{
public static void main(String args[])
{
int n ;
for(n=1;n<=20;n+=2)
{
System.out.println(n);
}
}
}
Hope this helps you.....
Pls mark me brainliest.....
Similar questions