English

Give two differences between Syntax error and Logical error. - Computer Applications

Advertisements
Advertisements

Question

Give two differences between Syntax error and Logical error. 

Distinguish Between

Solution

S. No. Syntax error  Logical error
1. Errors occur when programming principles or grammar are not followed correctly.  Errors occur when software logic is not planned correctly.
2. All syntax problems should be recognised and repaired. Otherwise, the software won't run. The computer is not aware that an error has occurred. The software executes, but the output may be incorrect.
3. Example: x = a + b
The above statement generates a syntax error due to a missing semicolon at the end.

To print numbers from 1 to 10,

for(int x = 1; x >= 10; x++)
System.out.println(x); 

The code above contains a logical mistake as the intended output requires x <= 10. 

 

shaalaa.com
  Is there an error in this question or solution?
Chapter 1.06: Input in Java - EXERCISES [Page 66]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 1.06 Input in Java
EXERCISES | Q IV. 6. | Page 66
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×