SlideShare a Scribd company logo
C-Language & Its
Errors
C-Language
C is a general-purpose high level language that was originally developed by Dennis Ritchie for
the Unix operating system. It was first implemented on the Digital Eqquipment Corporation
PDP-11 computer in 1972.
Dennis Ritchie
PDP-11 computer
Facts about C
• Easy to learn
• Structured language
• It produces efficient programs.
• It can handle low-level activities.
• It can be compiled on a variety of computers.
• The language was formalized in 1988 by ANSI.
Why to use C ?
C was initially used for system development work, in particular the programs that
make-up the operating system. C was adoped as a system development language
because it produces code that runs nearly as fast as code written in assembly
language. Some examples of the use of C might be:
• Operating Systems
• Language Compilers
• Assemblers
• Text Editors
All the C programs are writen into text files with extension ".c" for example
hello.c.
Errors
When we compile any C -program sometimes it give us a Bug or an Error.
Program errors are also referred to as program bugs.
A C program may have one or more of four types of errors:
• Syntax errors (Compiler errors or Compile-time errors)
• Linker Errors
• Runtime errors
• Logic errors
Usually, the errors become more difficult to find and fix.
Syntax Errors
The set of rules (grammatical rules) of a programming language for writing
statements of the computer program is known as syntax of the language.The
program statements are written strictly according to these rules.
Syntax error occur when syntax of a programming language are not followed
in writing the source code.The compiler detects these errors at compiling
time of source code.The compiler reports a proper error message about the
error.
The compiler does not compile a program that contain syntax errors.The
syntax errors are easy to detect and remove.
In C program, there can be many causes of syntax errors. Some examples are
given below:-
• Missing semicolon ( ; ) at the end of statement.
• Missing any of delimiters i.e { or }
• Incorrect spelling of any keyword.
• Using variable without declaration etc.
Syntax errors are the easiest to find and fix. Over the years, compiler developers
have worked hard to make compilers smarter so that they can catch errors at
compile time that might otherwise turn out to be runtime errors.
Examples
1. Simple statement not terminated by semicolon:
2. Using a variable before it is declared:
3. Missing closing parenthesis, ) , in the printf satatement:
Logical Errors
The errors in the logic of the program are called logical error.The compiler cannot detect logical
errors. A program with logical errors is compiled (translated) and run successfully but it does not
give correct result.
Logic errors are the hardest to find and fix because:
• The compiler does not detect these errors
• There is no indication of error when the program is executed.
• The program may produce correct results for some input data and wrong results for
other input data.
Example: The following program has a logic error in the 3rd printf statement
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int num1, num2;
printf("Enter the first integer: ");
scanf("%d", &num1);
printf("nEnter the second integer: ");
scanf("%d", &num2);
printf("n%d + %d = %dn", num1, num2, num1 * num2);
system("PAUSE");
return 0;
}
Examples
Result 2
Results
Notice that the program produces correct results for some input (num1 = 2, num2 = 2 and
num1 = 0, num2 = 0) and wrong results for others:
Runtime Errors
The errors that occur during the execution of program are called the runtime errors.These types
of errors may occur due to the following reasons.
• When the program attempts to perform an illegal operation such as dividing a number by
zero.
• If input data given to the program is not in a correct format or input data file is not found
in the specified path.
• If hardware problem occurs such as hard disk error, or disk full or printer error etc.
When a runtime error occurs, the computer stops the execution of program and displays an error
message.
To find the source of a run-time error in a program, usually a software called debugger is used.
Example:When the following program is executed and the user inputs 0 for num2, a run-time
error occurs due to division by zero in the expression num1 / num2
Examples
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int num1, num2;
printf("Enter the first integer: ");
scanf("%d", &num1);
printf("nEnter the second integer: ");
scanf("%d", &num2);
printf("n%d + %d = %d", num1, num2, num1
+ num2);
printf("n%d / %d = %d", num1, num2, num1
/ num2);
printf("n%d * %d = %dn", num1, num2,
num1 * num2);
system("PAUSE");
return 0;
}
Linker errors
Linker errors are generated when the linker
encounters what looks like a function call; but it
cannot find a function with that name.This is usually
caused by misspelling a C standard function (like
main) or not including the header file for a function.
Examples
1. Misspelling a standardC function:
Examples
2. Not including the header file for a function:
Dev C++ has an option that automatically includes standard header files. It is not
recommended to use this option, as it is CPU-intensive. To turn off this option use the
menus: Tools  Compiler Options  Settings  Linker and set "Do not use standard
system startup files or libraries" to Yes:
With the option turned off, not including a standard header file in your program will
generate a linker error:
C and its errors

More Related Content

What's hot

Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
TejaswiB4
 
Bootstrapping in Compiler
Bootstrapping in CompilerBootstrapping in Compiler
Bootstrapping in Compiler
Akhil Kaushik
 
Intro To Programming Concepts
Intro To Programming ConceptsIntro To Programming Concepts
Intro To Programming ConceptsJussi Pohjolainen
 
Presentation on C programming language
Presentation on C programming languagePresentation on C programming language
Presentation on C programming language
Arunima Education Foundation
 
Assembly language
Assembly languageAssembly language
Assembly language
gaurav jain
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
programming9
 
Linker and Loader
Linker and Loader Linker and Loader
Linker and Loader
sonalikharade3
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
programming9
 
C tokens
C tokensC tokens
C tokens
Manu1325
 
Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3
MOHIT TOMAR
 
System Programming Overview
System Programming OverviewSystem Programming Overview
System Programming Overview
Dattatray Gandhmal
 
Programming Fundamentals lecture 2
Programming Fundamentals lecture 2Programming Fundamentals lecture 2
Programming Fundamentals lecture 2
REHAN IJAZ
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
Rabin BK
 
Programming language
Programming languageProgramming language
Programming language
RajThakuri
 
High level and Low level Language
High level and Low level Language High level and Low level Language
High level and Low level Language
adnan usmani
 
Compilers
CompilersCompilers
Compilers
Bense Tony
 
OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++
Aabha Tiwari
 
The Phases of a Compiler
The Phases of a CompilerThe Phases of a Compiler
The Phases of a Compiler
Radhika Talaviya
 
System programming
System programmingSystem programming
System programming
jayashri kolekar
 
Control structure C++
Control structure C++Control structure C++
Control structure C++
Anil Kumar
 

What's hot (20)

Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
 
Bootstrapping in Compiler
Bootstrapping in CompilerBootstrapping in Compiler
Bootstrapping in Compiler
 
Intro To Programming Concepts
Intro To Programming ConceptsIntro To Programming Concepts
Intro To Programming Concepts
 
Presentation on C programming language
Presentation on C programming languagePresentation on C programming language
Presentation on C programming language
 
Assembly language
Assembly languageAssembly language
Assembly language
 
Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
 
Linker and Loader
Linker and Loader Linker and Loader
Linker and Loader
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
C tokens
C tokensC tokens
C tokens
 
Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3Header files of c++ unit 3 -topic 3
Header files of c++ unit 3 -topic 3
 
System Programming Overview
System Programming OverviewSystem Programming Overview
System Programming Overview
 
Programming Fundamentals lecture 2
Programming Fundamentals lecture 2Programming Fundamentals lecture 2
Programming Fundamentals lecture 2
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Programming language
Programming languageProgramming language
Programming language
 
High level and Low level Language
High level and Low level Language High level and Low level Language
High level and Low level Language
 
Compilers
CompilersCompilers
Compilers
 
OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++OPERATOR OVERLOADING IN C++
OPERATOR OVERLOADING IN C++
 
The Phases of a Compiler
The Phases of a CompilerThe Phases of a Compiler
The Phases of a Compiler
 
System programming
System programmingSystem programming
System programming
 
Control structure C++
Control structure C++Control structure C++
Control structure C++
 

Viewers also liked

Storage class in c
Storage class in cStorage class in c
Storage class in c
kash95
 
Storage Class in C Progrmming
Storage Class in C Progrmming Storage Class in C Progrmming
Storage Class in C Progrmming
Kamal Acharya
 
Storage classes in C
Storage classes in CStorage classes in C
Storage classes in C
Nitesh Bichwani
 
11 lec 11 storage class
11 lec 11 storage class11 lec 11 storage class
11 lec 11 storage classkapil078
 
Loops in C
Loops in CLoops in C
Loops in C
Kamal Acharya
 
Loops c++
Loops c++Loops c++
Loops c++
Shivani Singh
 
Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
Awais Alam
 
Arrays
ArraysArrays
Array in c language
Array in c languageArray in c language
Array in c languagehome
 

Viewers also liked (10)

Storage class in c
Storage class in cStorage class in c
Storage class in c
 
Storage Class in C Progrmming
Storage Class in C Progrmming Storage Class in C Progrmming
Storage Class in C Progrmming
 
Storage classes in C
Storage classes in CStorage classes in C
Storage classes in C
 
11 lec 11 storage class
11 lec 11 storage class11 lec 11 storage class
11 lec 11 storage class
 
Loops in C
Loops in CLoops in C
Loops in C
 
Loops c++
Loops c++Loops c++
Loops c++
 
Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
 
Arrays
ArraysArrays
Arrays
 
Array in c language
Array in c languageArray in c language
Array in c language
 
Storage class in C Language
Storage class in C LanguageStorage class in C Language
Storage class in C Language
 

Similar to C and its errors

Types of errors 2019
Types of errors 2019Types of errors 2019
Types of errors 2019
Osama Ghandour Geris
 
Unit 1 c - all topics
Unit 1   c - all topicsUnit 1   c - all topics
Unit 1 c - all topics
veningstonk
 
TYPES OF ERRORS.pptx
TYPES OF ERRORS.pptxTYPES OF ERRORS.pptx
TYPES OF ERRORS.pptx
muskanaggarwal84101
 
Fundamentals of programming with C++
Fundamentals of programming with C++Fundamentals of programming with C++
Fundamentals of programming with C++
Seble Nigussie
 
C lecture notes new
C lecture notes newC lecture notes new
C lecture notes new
Kuntal Bhowmick
 
(D 15 180770107240)
(D 15 180770107240)(D 15 180770107240)
(D 15 180770107240)
RaviModi37
 
What is turbo c and how it works
What is turbo c and how it worksWhat is turbo c and how it works
What is turbo c and how it works
Mark John Lado, MIT
 
The basics of c programming
The basics of c programmingThe basics of c programming
The basics of c programming
Muhammed Thanveer M
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
AashutoshChhedavi
 
Learn C Programming Full Course Free
Learn C Programming Full Course FreeLearn C Programming Full Course Free
Learn C Programming Full Course Free
Dheeraj Patidar
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
farishah
 
C programme presentation
C programme presentationC programme presentation
C programme presentation
DharmaKumariBhandari
 
1.1 programming fundamentals
1.1 programming fundamentals1.1 programming fundamentals
1.1 programming fundamentals
Jawad Khan
 
Computer and programing basics.pptx
Computer and programing basics.pptxComputer and programing basics.pptx
Computer and programing basics.pptx
gaafergoda
 
Software programming and development
Software programming and developmentSoftware programming and development
Software programming and development
Ali Raza
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
Subramanyambharathis
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
Vikram Nandini
 
CS3251-_PIC
CS3251-_PICCS3251-_PIC
1.Overview of Programming.pptx
1.Overview of Programming.pptx1.Overview of Programming.pptx
1.Overview of Programming.pptx
Vishwas459764
 

Similar to C and its errors (20)

Types of errors 2019
Types of errors 2019Types of errors 2019
Types of errors 2019
 
Unit 1 c - all topics
Unit 1   c - all topicsUnit 1   c - all topics
Unit 1 c - all topics
 
TYPES OF ERRORS.pptx
TYPES OF ERRORS.pptxTYPES OF ERRORS.pptx
TYPES OF ERRORS.pptx
 
Fundamentals of programming with C++
Fundamentals of programming with C++Fundamentals of programming with C++
Fundamentals of programming with C++
 
C lecture notes new
C lecture notes newC lecture notes new
C lecture notes new
 
(D 15 180770107240)
(D 15 180770107240)(D 15 180770107240)
(D 15 180770107240)
 
What is turbo c and how it works
What is turbo c and how it worksWhat is turbo c and how it works
What is turbo c and how it works
 
The basics of c programming
The basics of c programmingThe basics of c programming
The basics of c programming
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
 
Learn C Programming Full Course Free
Learn C Programming Full Course FreeLearn C Programming Full Course Free
Learn C Programming Full Course Free
 
Introduction of c language
Introduction of c languageIntroduction of c language
Introduction of c language
 
C programme presentation
C programme presentationC programme presentation
C programme presentation
 
Programming in c
Programming in cProgramming in c
Programming in c
 
1.1 programming fundamentals
1.1 programming fundamentals1.1 programming fundamentals
1.1 programming fundamentals
 
Computer and programing basics.pptx
Computer and programing basics.pptxComputer and programing basics.pptx
Computer and programing basics.pptx
 
Software programming and development
Software programming and developmentSoftware programming and development
Software programming and development
 
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdfINTRODUCTION TO C PROGRAMMING MATERIAL.pdf
INTRODUCTION TO C PROGRAMMING MATERIAL.pdf
 
C Programming Unit-1
C Programming Unit-1C Programming Unit-1
C Programming Unit-1
 
CS3251-_PIC
CS3251-_PICCS3251-_PIC
CS3251-_PIC
 
1.Overview of Programming.pptx
1.Overview of Programming.pptx1.Overview of Programming.pptx
1.Overview of Programming.pptx
 

Recently uploaded

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 

Recently uploaded (20)

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 

C and its errors

  • 1.
  • 3. C-Language C is a general-purpose high level language that was originally developed by Dennis Ritchie for the Unix operating system. It was first implemented on the Digital Eqquipment Corporation PDP-11 computer in 1972. Dennis Ritchie PDP-11 computer
  • 5. • Easy to learn • Structured language • It produces efficient programs. • It can handle low-level activities. • It can be compiled on a variety of computers. • The language was formalized in 1988 by ANSI.
  • 7. C was initially used for system development work, in particular the programs that make-up the operating system. C was adoped as a system development language because it produces code that runs nearly as fast as code written in assembly language. Some examples of the use of C might be: • Operating Systems • Language Compilers • Assemblers • Text Editors All the C programs are writen into text files with extension ".c" for example hello.c.
  • 9. When we compile any C -program sometimes it give us a Bug or an Error. Program errors are also referred to as program bugs. A C program may have one or more of four types of errors: • Syntax errors (Compiler errors or Compile-time errors) • Linker Errors • Runtime errors • Logic errors Usually, the errors become more difficult to find and fix.
  • 11. The set of rules (grammatical rules) of a programming language for writing statements of the computer program is known as syntax of the language.The program statements are written strictly according to these rules. Syntax error occur when syntax of a programming language are not followed in writing the source code.The compiler detects these errors at compiling time of source code.The compiler reports a proper error message about the error. The compiler does not compile a program that contain syntax errors.The syntax errors are easy to detect and remove.
  • 12. In C program, there can be many causes of syntax errors. Some examples are given below:- • Missing semicolon ( ; ) at the end of statement. • Missing any of delimiters i.e { or } • Incorrect spelling of any keyword. • Using variable without declaration etc. Syntax errors are the easiest to find and fix. Over the years, compiler developers have worked hard to make compilers smarter so that they can catch errors at compile time that might otherwise turn out to be runtime errors.
  • 13. Examples 1. Simple statement not terminated by semicolon:
  • 14. 2. Using a variable before it is declared:
  • 15. 3. Missing closing parenthesis, ) , in the printf satatement:
  • 17. The errors in the logic of the program are called logical error.The compiler cannot detect logical errors. A program with logical errors is compiled (translated) and run successfully but it does not give correct result. Logic errors are the hardest to find and fix because: • The compiler does not detect these errors • There is no indication of error when the program is executed. • The program may produce correct results for some input data and wrong results for other input data.
  • 18. Example: The following program has a logic error in the 3rd printf statement #include <stdio.h> #include <stdlib.h> int main(void) { int num1, num2; printf("Enter the first integer: "); scanf("%d", &num1); printf("nEnter the second integer: "); scanf("%d", &num2); printf("n%d + %d = %dn", num1, num2, num1 * num2); system("PAUSE"); return 0; } Examples
  • 19. Result 2 Results Notice that the program produces correct results for some input (num1 = 2, num2 = 2 and num1 = 0, num2 = 0) and wrong results for others:
  • 21. The errors that occur during the execution of program are called the runtime errors.These types of errors may occur due to the following reasons. • When the program attempts to perform an illegal operation such as dividing a number by zero. • If input data given to the program is not in a correct format or input data file is not found in the specified path. • If hardware problem occurs such as hard disk error, or disk full or printer error etc. When a runtime error occurs, the computer stops the execution of program and displays an error message. To find the source of a run-time error in a program, usually a software called debugger is used.
  • 22. Example:When the following program is executed and the user inputs 0 for num2, a run-time error occurs due to division by zero in the expression num1 / num2 Examples #include <stdio.h> #include <stdlib.h> int main(void) { int num1, num2; printf("Enter the first integer: "); scanf("%d", &num1); printf("nEnter the second integer: "); scanf("%d", &num2); printf("n%d + %d = %d", num1, num2, num1 + num2); printf("n%d / %d = %d", num1, num2, num1 / num2); printf("n%d * %d = %dn", num1, num2, num1 * num2); system("PAUSE"); return 0; }
  • 24. Linker errors are generated when the linker encounters what looks like a function call; but it cannot find a function with that name.This is usually caused by misspelling a C standard function (like main) or not including the header file for a function.
  • 25. Examples 1. Misspelling a standardC function:
  • 26. Examples 2. Not including the header file for a function:
  • 27. Dev C++ has an option that automatically includes standard header files. It is not recommended to use this option, as it is CPU-intensive. To turn off this option use the menus: Tools  Compiler Options  Settings  Linker and set "Do not use standard system startup files or libraries" to Yes:
  • 28. With the option turned off, not including a standard header file in your program will generate a linker error: