Troubleshooting a Boolean Expression Incrementing By 10

  • Thread starter Thread starter Mindscrape
  • Start date Start date
Click For Summary
SUMMARY

The discussion centers on troubleshooting a Boolean expression in a programming context, specifically related to incrementing a year variable by 10 in a while loop. The user initially faced compilation issues due to a typo, specifically forgetting to use the double equals sign (==) for comparison in the condition. Once the typo was corrected, the code functioned as intended, allowing for the output of values at intervals of ten years.

PREREQUISITES
  • Basic understanding of programming concepts, particularly loops and conditionals.
  • Familiarity with Boolean expressions and comparison operators.
  • Knowledge of syntax specific to the programming language being used (e.g., Java, C++).
  • Experience with debugging common coding errors.
NEXT STEPS
  • Review the use of comparison operators in your programming language of choice.
  • Practice writing and debugging while loops with conditional statements.
  • Explore common syntax errors and how to identify them in code.
  • Learn about best practices for code commenting to prevent similar issues.
USEFUL FOR

Beginner to intermediate programmers, software developers troubleshooting code, and anyone interested in improving their debugging skills.

Mindscrape
Messages
1,854
Reaction score
1
I am trying to make a table that will output a value every ten years. Basically, I am incrementing the year by 1 in a while loop, and I want it so every time year=10, 20, 30... that it will output a value. I have:

if (year%10 == 0) {
... code
}

For some reason the compiler has trouble compiling this.

*Nevermind, I had a typo and forgot the second =.
 
Last edited:
Physics news on Phys.org
Glad you figured it out.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K