0

In Game of fifteen we are asked to print a blank space at the end of the game, they fistly tell us to put the last number as any Int, then they ask us to print something that is not the int we chose, so I chose int blank = 0 and put the last space to print the blank, so its printing 0, but I want to print an _ symbol, how can i do that? Like this:

15 14 13 12

11 10  9  8

 7  6  5  4

 3  1  2  _

Mine is printing:

15 14 13 12

11 10  9  8

 7  6  5  4

 3  1  2  0
3

You may use an if/else statement like

if the current value is 0
    // do something
else
    // do something else
| improve this answer | |
  • Is this the only way? It seems like constantly checking for one value wouldn't be best practice. – Ian May 7 '16 at 3:26
  • even i am getting the same problem and when i tried to fix this by { char space=' '; char hash='-'; for(int i=15;i>=1;i--) { for(int j=i;j>=i-3;j--) { printf("%2d%c",j,space); while (j==1) { printf("%c",hash) } } i=i-3; printf("\n"); } } but this outputs infinite bunch of numbers,seems like when implementing j==1 condition ,loop gets repeated ,it doesn't end. – Himanshu Jhamb Jun 21 '16 at 5:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .