Computer Science, asked by DrStudy, 1 year ago

write a program in Java to print first 10 natural numbers using 'for' loop with correct syntax.​

Answers

Answered by moni5868
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 ayanaslam2005
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