Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Divide by zero???

 
Mark Henryson
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the below, Why divide by zero error is not raising? It is compiling and running without any exception. How?

 
Hentay Duke
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're incementing the value of i before it is used in the division, so divide by 0 is never happening.

Put a sysout to see tha value of i just after your sysout for the value of k and you'll see.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you ever divide by 0? Display i inside your loop and think about the first time through.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic