Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
1.00/5 (5 votes)
See more:
print numbers 1 to 4 on the same line, with each pair of adjacent number separated by one space

What I have tried:

int x=4;
        int i;
        for(i=1;i<=x;i++)
       
        System.out.printf("%d",i);
Posted
Updated 24-Apr-18 12:25pm
Comments
Richard MacCutchan 24-Apr-18 15:30pm    
You forgot the space.
Dave Kreskowiak 24-Apr-18 15:55pm    
So did you have a question?

1 solution

Java
System.out.println("1 2 3 4");
:-D
 
Share this answer
 
Comments
Peter_in_2780 24-Apr-18 18:31pm    
Damn! Beat me to it.
CPallini 25-Apr-18 3:50am    
You know, 'great minds think alike'. :-D
Richard Deeming 25-Apr-18 14:03pm    
Surely that should be:
System.out.println("numbers 1 to 4 on the same line, with each pair of adjacent number separated by one space");
:)
CPallini 25-Apr-18 14:10pm    
:-D :thumbsup:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900