[go: up one dir, main page]

0% found this document useful (0 votes)
11 views8 pages

Tyes of Errors

Nothing much but Some types of Errors people face in writing a program.

Uploaded by

mrabdulff2001
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)
11 views8 pages

Tyes of Errors

Nothing much but Some types of Errors people face in writing a program.

Uploaded by

mrabdulff2001
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/ 8

Chapter no:

Computer Science

Errors in C-Language

Presented by:
Rehan Khalid, Abdul
Rehman
Errors in C-Language

There are three types of error in


computer languages, Following are
these errors:
• Syntax Error
• Logical Error
• Run-time Error
1) Syntax Error:-
• Set of rules to write a program in programing
language.
• If doesn’t follow then a compiler will detect an error

Examples
• Missing a delimiters somewhere in a program.
• Incorrect spelling of keyword shall generate Syntax
Error
• Missing a terminator at the end of a statement .
Program 1.1:-
#include<stdio.h>
#include<conio.h>
void main()
{ Terminator
is missing
int a;
clrscr()
a=10
printf(“Enter a value”);
scanf(“%d”,&a);
getch()
}
2) Logical Error:-
• An error that occurs due to poor logic of
programmer
• Produces unexpected result of program.
• Can’t be detected by compiler.

Examples.

• Using wrong condition like a<5 instead of a>5.


• Using wrong formula.
Program 1.2:-
#include<stdio.h>
#include<conio.h>
void main()
{ Wrong
int a; condition
clrscr()
a=3;
If(a>4)
printf(“Number is lesser.”);
else
printf(“Number is greater.”);
getch()
}

Expected Output:- Given output:


Number is lesser. Number is greater.
3) Run-time Error:-
• Occurs during execution of program.
• When statement directs computer to execute
illegal operation.
• Computer detects and displays the error.

Example.
• User ask program to open a file that does not
exist.
• User enter wrong data etc.
Program 1.3:-
#include<stdio.h>
#include<conio.h>
void main()
{
int a; illegal
statement
a=5;
a=a/0;
printf(“%d”,a);
getch()
}

You might also like