🚫 1. Using =
Instead of ==
in Conditions (C++, C#)
if (x = 5) // Wrong: assigns 5 to x instead of comparing
if (x == 5) // Correct
Beginners often confuse assignment (=
) with comparison (==
). This can lead to unexpected bugs.
🚫 2. Indentation Issues (Python)
if x == 5:
print("Hello") # Wrong
Python relies on indentation for blocks. Forgetting or misaligning it causes errors.
🚫 3. Forgetting to Initialize Variables
C++/C#: Uninitialized variables may hold garbage values.
int score; // May contain random data!
cout << score;
Always assign default values before using.
🚫 4. Not Understanding Data Types
int result = 10 / 3; // Result: 3, not 3.33!
In C# and C++, integer division drops decimals. Use float
or double
when needed.
🚫 5. Using ==
to Compare Strings (C++, C#)
string name = "John";
if (name == "John") // ❌ Not reliable in C++
In C++, use .compare()
or ==
from the standard string class. In C#, ==
works, but be cautious with object references.
🚫 6. Missing Brackets or Colons
- Python: Missing
:
in if
, for
, or def
statements.
- C++/C#: Missing
{}
can lead to unexpected flow.
🚫 7. Infinite Loops by Mistake
while x != 5:
print("Running") # If x is never 5, loop runs forever
Always check that your loop has an exit condition.
🚫 8. Case Sensitivity Confusion
Name = "John"
print(name) # Error: Python is case-sensitive!
Variables like Name
and name
are different in all three languages.
🚫 9. Misusing Logical Operators (&&
, ||
, and
, or
)
if (age > 18 & hasID) // ❌ Bitwise AND
if (age > 18 && hasID) // ✅ Logical AND
Use the correct logical operators. Python uses and
, or
; C++/C# use &&
, ||
.
🚫 10. Forgetting to Close Files or Resources
file = open("data.txt", "r")
# Forgot to close it!
Always use proper file handling:
- Python:
with open(...) as file:
- C++:
file.close();
- C#: use
using
block