• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with code for printing a pattern on screen  RSS feed

 
akshat khandelwal
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

expected output pattern of this program was:
1
2 2 2
3 3 3 3 3
4 4 4 4 4 4 4


but actual output of this program is :
1
2 2
3 3 3
4 4 4 4


CAN ANYONE TELL ME WHAT IS THE PROBLEM WITH MY CODE ???
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37513
554
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This line of code increments the number of characters by one each time. So you have the output of 1, 2, 3 and 4 characters respectively.


Since you want 1, 3, 5 and 7 characters, you need to increment by 2.

ps - all caps on the internet is consider "shouting"
 
akshat khandelwal
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the use of caps. I was unaware of this thing.
and thank you sir @Jeanne Boyarsky
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!