In C programming, debugging is done at every stage of program. While designing software all types of errors are checked and debugging is done.
Program design in C:
- We call it as different steps or set of instructions decided by the programmer before he writes the code in particular language.
- It is necessary as before construction of building, the actual building plan is required.
- This design guides the programmer during actual coding process and also important during the execution of our plan.
- This is important step during software development.
Debugging is:
When programmer writes codes for any software, he has to check whether the code is right or wrong, if wrong he has to correct it. Means programmer has to check every step of code find any mistake and correct it or remove it for good work of software, this process is called as debugging.
This is most important part of testing process but if programmer does it at every function code, it will reduce testing time significantly.
Types of errors:
While during coding, there will be occurrence of various errors and these are divided into 3 types.
These are given below:
- Syntax Errors
- Logical Errors
- Runtime Errors
1. Syntax Errors
- We can also call it as grammatical errors in programming language. Like English language every language has its own set of rule or dictionary.
- In programming language their rules are different for declaring variables, writing instructions, etc. If we have made mistake while writing, these errors are called as syntax errors.
- In some programming we find these errors when we are typing the program or sometime during compiling.
Let us take an example −
We find the error as prod variable is not defined.
2. Semantic / Logical Errors
- Consider an example, when we are giving some instruction to the friend but he is not doing the task properly and we did not get the desired result, in such situation we can say it as logical error in programming language.
- In programming, we write the program, we did not get any syntax error, so program compilation goes correctly and it run also very well but we did not found the desired output as logic is wrong.
Consider a program to illustrate logical error:
#include <stdio.h>
#include<conio.h>
int main()
{
int a,b,c;
printf(“Enter values of a & b:”);
scanf(“%d%d”,&a,&b);
if (b= 0)
printf(“We can not divide by zero”);
else
{
c=a/b;
printf(“Division=%d\n”,ci);
}
return 0;
}
Explanation about error:
Look at statement if (b=0)
We wants to check if the divisor is 0, to avoid division by 0. We are using assignment operator =, instead of using the comparing operator ==. Every time this if statement gets true and program will give output as “You cannot divide by 0”, which is wrong.
These errors are identified by programmer only to get correct output, but not detected by the program.
3. Runtime Errors
At the time of execution this error occurs which shows that the program has no syntax errors. Some common run time errors:
- Infinite loop
- Division by ‘0’
Related Articles:
- Basic Accounting Concepts Part 1
debugging isdesigning softwarefacebook debuggergdb debuggerjavascript debuggeronline debuggerpython debuggertypeerror
Debugging is | designing software
2022-11-15
Computer Basics
No Comments
Admin
In C programming, debugging is done at every stage of program. While designing software all types of errors are checked and debugging is done.
Program design in C:
Debugging is:
When programmer writes codes for any software, he has to check whether the code is right or wrong, if wrong he has to correct it. Means programmer has to check every step of code find any mistake and correct it or remove it for good work of software, this process is called as debugging.
This is most important part of testing process but if programmer does it at every function code, it will reduce testing time significantly.
Types of errors:
While during coding, there will be occurrence of various errors and these are divided into 3 types.
These are given below:
1. Syntax Errors
Let us take an example −
We find the error as prod variable is not defined.
2. Semantic / Logical Errors
Consider a program to illustrate logical error:
#include <stdio.h>
#include<conio.h>
int main()
{
int a,b,c;
printf(“Enter values of a & b:”);
scanf(“%d%d”,&a,&b);
if (b= 0)
printf(“We can not divide by zero”);
else
{
c=a/b;
printf(“Division=%d\n”,ci);
}
return 0;
}
Explanation about error:
Look at statement if (b=0)
We wants to check if the divisor is 0, to avoid division by 0. We are using assignment operator =, instead of using the comparing operator ==. Every time this if statement gets true and program will give output as “You cannot divide by 0”, which is wrong.
These errors are identified by programmer only to get correct output, but not detected by the program.
3. Runtime Errors
At the time of execution this error occurs which shows that the program has no syntax errors. Some common run time errors:
Related Articles:
Some More: DBMS/ WT/ DMDW
debugging isdesigning softwarefacebook debuggergdb debuggerjavascript debuggeronline debuggerpython debuggertypeerror