Print numbers till the given number using for loop - Java Quiz Question


Write a program using for loop to print the numbers till the given input. Spaces between numbers are important and they should be in one line. Use System.out.println or System.out.print for printing.

Integer (Input) Printed Output
4 1 2 3 4
7 1 2 3 4 5 6 7
10 1 2 3 4 5 6 7 8 9 10



class PrintNumbersUsingFor
{
    public static void main(String s[])
    {
        printNumbers(5);

    }


    public static void printNumbers(int input)
    {
    }

}