• Post Reply Bookmark Topic Watch Topic
  • New Topic

Improper output for the code  RSS feed

 
Aliya Khanum
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Here is the code which I executed in netbeans IDE for which I am not supposed to get any output but I get 7 times Big x in my output.
But when I change the while condition to (x<2) I get the desired output. And when I say while(x<12) I get 9 times Big x in my output.
Can somebody help me with what is going wrong.



Thank you.
 
Tapas Chand
Ranch Hand
Posts: 614
9
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The program is behaving as it should. There is nothing wrong.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Aliya, and welcome to the Ranch! When you post code, always UseCodeTags <- link

I've added them for you this time, and doesn't that look better?
 
Knute Snortum
Sheriff
Posts: 4281
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Maybe it would help if you posted the exercise and tell us where it came from. The code you posted prints "Big x" seven time just as I would expect. Why are you expecting no output?
 
Aliya Khanum
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, Right I didn't trace properly but now I got it.
Thank you for all your help.
 
Campbell Ritchie
Marshal
Posts: 56576
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aliya Khanum wrote: . . . now I got it.
Thank you for all your help.
I presume that means the output is now correct?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!