Beruflich Dokumente
Kultur Dokumente
B. V. Bhoomaraddi. College of
Engineering and Technology
Contents
TYPES OF ERRORS/BUGS
Types of Bugs/Errors
Syntax Errors A syntax error refers to a mistake in a
statement's syntax.
Syntax Errors
A syntax error refers to a mistake in a
statement's syntax.
if (age >=60 );
printf(“Senior citizen”); Unnecessary
semi-colon
If (age >=3 && age <=5 )
printf(“LKG to UKG”);
else if (age >=6 && age<=12);
printf(“Primary School”);
else if (age >=13 && age <=16)
printf(“High School”);
if (n%7=0) Why?
printf(“%d is divisible by 7\n”, n);
else
printf(“%d is NOT divisible by 7\n”, n);
Sl.No
C Statement
1 printf(“%d %d” i,j);
2 printf(“%d %d”, “i=“,i);
3 scanf(“%d”, &i, &j);
4 printf(“%d %d”, 10);
5 printf(“%d %d”, 1 % 2, ‘I’);
6 Int A,B;
7 Float rate = 3.7:
3/11/2018 K. L. E. Technological University, Hubli- 11
31.
KLE Society’s
B. V. Bhoomaraddi. College of
Engineering and Technology
Logical Errors
A Logical Error in a program causes
unexpected results or operation but not
failure.
Cannot be checked by the compilers, as the
program is syntactically correct.
These are usually the hardest to debug
because they do not cause the program to
fail completely.
3/11/2018 K. L. E. Technological University, Hubli- 12
31.
KLE Society’s
B. V. Bhoomaraddi. College of
Engineering and Technology
Logical Errors??
1. Use of = instead of ==
2. iteration without a body (for/while followed by a
semi-colon)
3. uninitialized variable
4. infinite iteration
5. incorrect operator order in a compound expression
6. dangling else
7. off-by-one iteration
8. integer division and truncation
9. mis-matched data types
10. & instead of &&
3/11/2018 K. L. E. Technological University, Hubli- 13
31.
KLE Society’s
B. V. Bhoomaraddi. College of
Engineering and Technology
2. int a=10;
if(a=2)
{
printf(“The value of a is 2\n”);
}
else
{
printf(“The value of a is not 2\n”);
}
3/11/2018 K. L. E. Technological University, Hubli- 14
31.
KLE Society’s
B. V. Bhoomaraddi. College of
Engineering and Technology
Runtime Errors
{
int a,b;
float r;
scanf(“%d %d”, &a,&b);
r=a/b;
printf(“Result=%d”,r);
}
3/11/2018 K. L. E. Technological University, Hubli- 16
31.
KLE Society’s
B. V. Bhoomaraddi. College of
Engineering and Technology
STEPS IN DEBUGGING
#include<stdio.h> #include<stdio.h>
main() main()
{ {
int a; int a;
scanf (“%d”, &a) scanf (“%d”, &a);
printf (“%d, &a); printf (“%d” a);
} }
END OF SESSION