write a program in Java to print first 10 natural numbers using 'for' loop with correct syntax.
Home
/
Computer Science
/
write a program in Java to print first 10 natural numbers using 'for' loop with correct syntax.
write a program in Java to print first 10 natural numbers using 'for' loop with correct syntax.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
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
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.....