Computer Science, asked by Anonymous, 1 month ago

write a program in JAVA to print natural number from 3 to 36​

Answers

Answered by anindyaadhikari13
6

\texttt{\textsf{\large{\underline{Solution}:}}}

The given problem is solved using language - Java.

public class Series{

   public static void main(String s[]){

       System.out.println("Natural numbers from 3 to 36 are - ");

       for(int i=3;i<=36;)

           System.out.print(i++ +" ");

   }

}

\texttt{\textsf{\large{\underline{Explanation}:}}}

  • Line 1: Start of class.
  • Line 2: Start of main() method.
  • Line 3: Displays a message on the screen.
  • Line 4: Loop created to display the numbers.
  • Line 5: The numbers are displayed using print() statement.
  • Line 6: End of main().
  • Line 7: End of class.

See attachment for output.

Attachments:
Answered by kamalrajatjoshi94
2

Answer:

Program:-

public class Main

{

public static void main(String args[])

{

int i;

for(i=3;i<=36;i++)

{

System.out.println(i);

}

}

}

Attachments:
Similar questions