SlideShare a Scribd company logo
1 of 13
PROGRAMMING ERRORS
WITH NEHA SHARMA
SYNTAX ERROR
SEMANTIC ERROR
LOGICAL ERROR
RUNTIME ERROR
Programming Error or bug
Unexpected output produced by program is called Error or bug
ERROR BUG
Found by
Developer
Found by
Tester
Debugging
Process of finding and removing errors in the program is called debugging
SYNTAX
ERROR
Invalid
statement
written in
code
SEMANTIC
ERROR
Meaningless
statements in
the code
LOGICAL
ERROR
Poor logics
in the code
RUNTIME
ERROR
Error in
execution of
successful
compilation
of code
TYPES OF ERROR
SYNTAX ERROR
-- It occurs due to the violation of syntax or grammatical rules
-- These errors are detected at compile time.
Missing semicolon and
datatype
Error in expression
//C++ program to illustrate syntax error
#include<iostream.h>
void main()
{
x = 10; // Error: Undeclared identifier x
int y = 15;
cout <<“value of x and y” <<x<<y
//Error : ';' expected
}
SYNTAX ERROR
-- It occurs due to the violation of one or more grammar rules.
-- These errors are detected at compile time.
C++ program to illustrate syntax error
#include<iostream.h>
void main()
{
int x = ( 3 + 5; // missing closing parenthesis ‘)’
int y = 3 + * 5; // missing argument between '+'
and ‘*’
}
Error in expression
Missing semicolon and
datatype
SEMANTIC ERROR
-- It occurs when the statements written in the program are not
meaningful to the compiler.
-- Difficult to detect because their syntax is correct but their
meaning is wrong.
//C++ program to illustrate semantic error
#include<iostream.h>
void main()
{
int a, b, c;
a + b = c;
//Error: lvalue required as left operand of
assignment
}
SEMANTIC ERROR
-- It occurs when the statements written in the program are not
meaningful to the compiler.
-- Difficult to detect because their syntax is correct but their
meaning is wrong.
//C++ program to illustrate semantic error
#include<iostream.h>
int main ()
{
int i;
i++; //Error: The variable ‘i’ is not
initialized
}
SEMANTIC ERROR
-- It occurs when the statements written in the program are not
meaningful to the compiler.
-- Difficult to detect because their syntax is correct but their
meaning is wrong.
C++ program to illustrate semantic error
#include<iostream.h>
void main()
{
int i= “Hello”
//Error: cannot convert 'char *' to 'int'
}
LOGICAL ERROR
-- It occurs because of wrong programming designing
-- Program with logical error are executed. But, does not generate the
requested result.
//C++ program to illustrate logical error
#include<iostream.h>
int main ()
{
for( ; ; )
{
cout<< "This loop will run forever” ;
}
return 0;
}
Infinite Loop
Errors in performed
computation
LOGICAL ERROR
-- It occurs because of wrong programming designing
-- Program with logical error are executed. But, does not generate the
requested result.
//C++ program to illustrate logical error
#include<iostream.h>
int main () // program: sum of two numbers
{
int a, b;
c= a-b;
cout<< “sum of two number is”<< c;
// This will always return wrong value wrt
specification required was sum of two numbers
}
Errors in performed
computation
Infinite Loop
RUNTIME ERROR
-- It occurs during program execution after successful compilation
--It occurs due to performing illegal operations.
-- It leads to abnormal termination of the program.
//C++ program to illustrate runtime error
#include<iostream.h>
void main()
{
int n = 9, div = 0;
div = n/0; // Error: number is divided by 0,
cout<<“The result is”<<div;
//This program abnormally terminates
}
RUNTIME ERROR
-- It occurs during program execution after successful compilation
--It occurs due to performing illegal operations.
-- It leads to abnormal termination of the program.
//C++ program to illustrate runtime error
#include<iostream.h>
void main()
{
char *ptr;
*ptr= 3; // Error: point illegal memory space
}
CONCLUSION

More Related Content

What's hot

What's hot (20)

Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
 
Array ppt
Array pptArray ppt
Array ppt
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
MS Word Basics
MS Word BasicsMS Word Basics
MS Word Basics
 
Object Oriented Paradigm
Object Oriented ParadigmObject Oriented Paradigm
Object Oriented Paradigm
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Translators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreterTranslators(Compiler, Assembler) and interpreter
Translators(Compiler, Assembler) and interpreter
 
Structure of a C program
Structure of a C programStructure of a C program
Structure of a C program
 
Introduction of c programming
Introduction of c programmingIntroduction of c programming
Introduction of c programming
 
Looping statement in python
Looping statement in pythonLooping statement in python
Looping statement in python
 
High level languages representation
High level languages representationHigh level languages representation
High level languages representation
 
Java features
Java featuresJava features
Java features
 
Programming Fundamentals
Programming FundamentalsProgramming Fundamentals
Programming Fundamentals
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
 
Function in C program
Function in C programFunction in C program
Function in C program
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
CSharp Presentation
CSharp PresentationCSharp Presentation
CSharp Presentation
 

Similar to Types of Programming Errors

Similar to Types of Programming Errors (20)

Hello world! Intro to C++
Hello world! Intro to C++Hello world! Intro to C++
Hello world! Intro to C++
 
(D 15 180770107240)
(D 15 180770107240)(D 15 180770107240)
(D 15 180770107240)
 
TYPES OF ERRORS.pptx
TYPES OF ERRORS.pptxTYPES OF ERRORS.pptx
TYPES OF ERRORS.pptx
 
Python Introduction
Python IntroductionPython Introduction
Python Introduction
 
OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++
 
Incredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and GeneratorsIncredible Machine with Pipelines and Generators
Incredible Machine with Pipelines and Generators
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
 
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-stringsDevry cis-170-c-i lab-5-of-7-arrays-and-strings
Devry cis-170-c-i lab-5-of-7-arrays-and-strings
 
Programming
ProgrammingProgramming
Programming
 
Applying Anti-Reversing Techniques to Machine Code
Applying Anti-Reversing Techniques to Machine CodeApplying Anti-Reversing Techniques to Machine Code
Applying Anti-Reversing Techniques to Machine Code
 
C++ programming language basic to advance level
C++ programming language basic to advance levelC++ programming language basic to advance level
C++ programming language basic to advance level
 
C++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWAREC++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWARE
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
 
Lec1_EENG112-Introduction.pdf
Lec1_EENG112-Introduction.pdfLec1_EENG112-Introduction.pdf
Lec1_EENG112-Introduction.pdf
 
Basics Of C++.pptx
Basics Of C++.pptxBasics Of C++.pptx
Basics Of C++.pptx
 
Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsDevry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and strings
 
Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsDevry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and strings
 
Logical Expressions in C/C++. Mistakes Made by Professionals
Logical Expressions in C/C++. Mistakes Made by ProfessionalsLogical Expressions in C/C++. Mistakes Made by Professionals
Logical Expressions in C/C++. Mistakes Made by Professionals
 
Building Simple C Program
Building Simple  C ProgramBuilding Simple  C Program
Building Simple C Program
 

Recently uploaded

Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
jaanualu31
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 

Recently uploaded (20)

Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
kiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal loadkiln thermal load.pptx kiln tgermal load
kiln thermal load.pptx kiln tgermal load
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 

Types of Programming Errors

  • 1. PROGRAMMING ERRORS WITH NEHA SHARMA SYNTAX ERROR SEMANTIC ERROR LOGICAL ERROR RUNTIME ERROR
  • 2. Programming Error or bug Unexpected output produced by program is called Error or bug ERROR BUG Found by Developer Found by Tester Debugging Process of finding and removing errors in the program is called debugging
  • 3. SYNTAX ERROR Invalid statement written in code SEMANTIC ERROR Meaningless statements in the code LOGICAL ERROR Poor logics in the code RUNTIME ERROR Error in execution of successful compilation of code TYPES OF ERROR
  • 4. SYNTAX ERROR -- It occurs due to the violation of syntax or grammatical rules -- These errors are detected at compile time. Missing semicolon and datatype Error in expression //C++ program to illustrate syntax error #include<iostream.h> void main() { x = 10; // Error: Undeclared identifier x int y = 15; cout <<“value of x and y” <<x<<y //Error : ';' expected }
  • 5. SYNTAX ERROR -- It occurs due to the violation of one or more grammar rules. -- These errors are detected at compile time. C++ program to illustrate syntax error #include<iostream.h> void main() { int x = ( 3 + 5; // missing closing parenthesis ‘)’ int y = 3 + * 5; // missing argument between '+' and ‘*’ } Error in expression Missing semicolon and datatype
  • 6. SEMANTIC ERROR -- It occurs when the statements written in the program are not meaningful to the compiler. -- Difficult to detect because their syntax is correct but their meaning is wrong. //C++ program to illustrate semantic error #include<iostream.h> void main() { int a, b, c; a + b = c; //Error: lvalue required as left operand of assignment }
  • 7. SEMANTIC ERROR -- It occurs when the statements written in the program are not meaningful to the compiler. -- Difficult to detect because their syntax is correct but their meaning is wrong. //C++ program to illustrate semantic error #include<iostream.h> int main () { int i; i++; //Error: The variable ‘i’ is not initialized }
  • 8. SEMANTIC ERROR -- It occurs when the statements written in the program are not meaningful to the compiler. -- Difficult to detect because their syntax is correct but their meaning is wrong. C++ program to illustrate semantic error #include<iostream.h> void main() { int i= “Hello” //Error: cannot convert 'char *' to 'int' }
  • 9. LOGICAL ERROR -- It occurs because of wrong programming designing -- Program with logical error are executed. But, does not generate the requested result. //C++ program to illustrate logical error #include<iostream.h> int main () { for( ; ; ) { cout<< "This loop will run forever” ; } return 0; } Infinite Loop Errors in performed computation
  • 10. LOGICAL ERROR -- It occurs because of wrong programming designing -- Program with logical error are executed. But, does not generate the requested result. //C++ program to illustrate logical error #include<iostream.h> int main () // program: sum of two numbers { int a, b; c= a-b; cout<< “sum of two number is”<< c; // This will always return wrong value wrt specification required was sum of two numbers } Errors in performed computation Infinite Loop
  • 11. RUNTIME ERROR -- It occurs during program execution after successful compilation --It occurs due to performing illegal operations. -- It leads to abnormal termination of the program. //C++ program to illustrate runtime error #include<iostream.h> void main() { int n = 9, div = 0; div = n/0; // Error: number is divided by 0, cout<<“The result is”<<div; //This program abnormally terminates }
  • 12. RUNTIME ERROR -- It occurs during program execution after successful compilation --It occurs due to performing illegal operations. -- It leads to abnormal termination of the program. //C++ program to illustrate runtime error #include<iostream.h> void main() { char *ptr; *ptr= 3; // Error: point illegal memory space }

Editor's Notes

  1. Hello Friends. in previous video we learned the concept of oops plus coding in c++, now we will discuss what all errors we face while running a program.
  2. Unexpected output produced by program is called Error or bug. Error is found by developer during coding where as bugs are found by the tester when the project is done. Some of the errors do not let program to be compiled and executed. For that debugging is required: debugging is a process of finding and removing errors in the program
  3. The most common errors can be broadly classified as follows. Let us now understand these errors with example using c++ and also how to fix them.
  4. First is syntax error: It occurs due to the violation of syntax or grammatical rules which is detected at compile time. Most frequent syntax errors are: --Missing datatype: datatype of x is missing which will generate an error: Undeclared identifier x --Missing semicolon: as you can see cout statement misses semicolon and in c++ it is mandatory to end the statement with ; so it will generate error.
  5. --second is: error in the expression: here in second statement: closing parenthesis for the expression is missing and in fourth statement: arguments between the operators.
  6. Now : Semantic error: It occurs when the statements written in the program are not meaningful to the compiler. It is difficult to detect because their syntax is correct but their meaning is wrong. These are detected either at compile time or runtime. Lets take example: -- Wrong statement: If some expression is given at the left side of assignment operator, this may generate semantic error.
  7. Next is Use of non-initialized variable: variable i has not been assigned any value before incrementing which will cause an error.
  8. Another is type incompatibility: Assigning a string value to integer type variable will produce an error as compiler can not convert string into integer. Fortunately, compiler generally catches both syntax and semantic errors and generate warnings or errors, so you easily identify and fix the problem
  9. Third type of error is Logical error. It occurs because of wrong programming design. Though program is executed as there is no syntax or semantic error but do not generate the desired results. --First is Infinite loop: When the conditional expression is absent, it is assumed to be true, leading to endless loop which is undesirable result. You can terminate an infinite loop by pressing Ctrl + C keys.
  10. Next is: errors in performed computation. Like here we want the addition as the output of two numbers but due to coding wrong expression i.e. subtraction, we got the wrong result. Manually the code should be checked to locate logical errors.
  11. Last is the Runtime error: It occurs during program execution after successful compilation due to illegal operations which leads to abnormal termination. The general cause of Run time errors is because your program is trying to perform an operation that is impossible to carry out. --Like: Division error: i.e. dividing a no. by 0 which will terminate the program abnormally.
  12. Next is pointing to null pointer: If you try to access or declare a null pointe: it will generate an error. Exception handling is used to avoid such runtime errors.
  13. Finally concluding, first we discussed what is programming error and bugs. Then we discussed types of error with examples with way of finding and removing error. That’s all friends, if you like the video please click the like button and for more such technical videos please subscribe the channel.