[go: up one dir, main page]

0% found this document useful (0 votes)
10 views10 pages

Common Programming Errors

This ppt introducesthe common programming error
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views10 pages

Common Programming Errors

This ppt introducesthe common programming error
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Week 5:

Common Programming
ERRORS
I T E 1 2 – Fu n d a m e n t a l s o f P r o b l e m S o l v i n g a n d P r o g r a m m i n g
C O L L E G E O F C O M P U T I N G A N D I N F O R M AT I O N S C I E N C E S

ITE 15
Contents

Common Programming Errors:


 Syntax Errors
 Run-Time Errors
 Logic Errors

ITE 111 – COMPUTER FUND. & PROG., COLLEGE OF COMPUTING & INFORMATION SCIENCES
Common Programming Errors
 Errors are so common that they have their own special name—
bugs

 The process of correcting bug is called debugging a program.

 According to computer folklore, computer pioneer Dr. Grace


Murray Hopper diagnosed the first hardware error caused by a
large insect found inside a computer component.

 The Compiler detects an error and displays an error message.

 Error messages are often difficult to interpret and are


sometimes misleading.
ITE 111 – COMPUTER FUND. & PROG., COLLEGE OF COMPUTING & INFORMATION SCIENCES
1. Syntax Errors
 Detected by Compiler.
 When your code violates one or more grammar rules of C.
 Then your program will not be translated and executed.
 Lines marked for an error is not always the lines containing the
programmer’s mistake.
 Similar errors messages are displayed for every repetition of error
variables.
 Correcting syntax errors should take into account the fact that one
error can lead to many error messages.

 It is often a good idea to concentrate on correcting the


errors in the declaration part of a program first. Then
recompile the program before you attempt to fix other
errors.
ITE 111 – COMPUTER FUND. & PROG., COLLEGE OF COMPUTING & INFORMATION SCIENCES
Syntax Error Example No. 1

ERROR MESSAGE: undefined reference to


‘prinf’
ITE 111 – COMPUTER FUND. & PROG., COLLEGE OF COMPUTING & INFORMATION SCIENCES
Syntax Error Example No. 2

ERROR MESSAGE @ line 11: expected ‘;’


ERROR MESSAGE @ line 13: ‘area’ undeclared (first use
before scanf
ITE 111 – COMPUTER FUND. & PROG., COLLEGE OF COMPUTING & INFORMATION SCIENCES

in this function)
Syntax Error Example No. 3

ERROR MESSAGE @ line 6: invalid operands to binary & (have ‘int *’


and ‘int’)MESSAGE @ line 10: expected ‘)’ before ‘c’
ERROR
ITE 111 – COMPUTER FUND. & PROG., COLLEGE OF COMPUTING & INFORMATION SCIENCES
2. Run-Time Errors
 Detected and displayed by the computer during the
execution of a program.
 It occurs when the program directs the computer to
perform an illegal operation.
 dividing a number by zero

 When a run-time error occurs, the computer will stop


executing your program and will display a diagnostic
message that indicates the line where the error was
detected.

ITE 111 – COMPUTER FUND. & PROG., COLLEGE OF COMPUTING & INFORMATION SCIENCES
3. Logic Errors
 Occur when a program follows a faulty
algorithm.
 Usually do not cause run-time errors and do not
display error messages
 very difficult to detect.
 The only sign of a logic error may be incorrect
program output.
 You can detect logic errors by testing the
program thoroughly.

ITE 111 – COMPUTER FUND. & PROG., COLLEGE OF COMPUTING & INFORMATION SCIENCES
References
 Aksum University, Department of Computing Technology
 https://docureader.com/preview/y5kp17mneeod/integrative-programming-
and-technologies-chapter-1

ITE 111 – COMPUTER FUND. & PROG., COLLEGE OF COMPUTING & INFORMATION SCIENCES

You might also like