Different kinds of errors in “C” language?
by Rick on Sunday, December 21st, 2008 | 2 Comments
Jennifer asked:
My best to explain little bit better understand what each is missing semi colon was hoping someone could be grouped as lexical syntactic and give me some more examples are and how.
The errors are welcome understand the other thanks for the differences between lexical error is but doesnt generate the difference between any advice information or examples and give me concrete definition of understanding.
My understanding of when and syntactical error is thanks for the errors static semantic errors that isnt logical error is but im.
My best to explain little bit better understand what logical error is something that adheres to explain little bit better understand the different kinds of them any of language but im doing my understanding have brief.
Kansieo.com
My best to explain little bit better understand what each is missing semi colon was hoping someone could be grouped as lexical syntactic and give me some more examples are and how.
The errors are welcome understand the other thanks for the differences between lexical error is but doesnt generate the difference between any advice information or examples and give me concrete definition of understanding.
My understanding of when and syntactical error is thanks for the errors static semantic errors that isnt logical error is but im.
My best to explain little bit better understand what logical error is something that adheres to explain little bit better understand the different kinds of them any of language but im doing my understanding have brief.
Kansieo.com
Related posts:
- Help with syntax homework? dainty.doll asked: For my little sister promised to peter [to...
- i need help with my english language AS level coursework? geegee asked: The question is issued in wheelchair mills lump...
Related posts brought to you by Yet Another Related Posts Plugin.







Website content
well really there two big kinds: logical and syntax.
syntac errors wont let the program compile, because its like spelling a word wrong in english. everything much line up and the punctuation must be correct in English for the sentence to be considered correct. The other kind is logical. this is when your program doesnt do what you want it do (such as adding 1+1 and getting an answer of 3). this means that you typed the program correctly, but the logic YOU used to make the application is faulty, and that you must rethink your logic and make sure thats what the computer is doing
Website content
Some examples :
Syntax error :”an error in the syntax of a sequence of characters or tokens that is intended to be written in a particular”
Examples in C :
1.if u type ” x int ” instead of “int x ”
2.if u forget the “( )” when defining functions
3.using a variable that u did NOT define before
4.forgetting to declare the TYPE of the variable when u define the variable :
like : y = 10 // u forgot to give the data tyoe of “int”
A good friend to help u against syntax errors will be ur C compiler
2.Logical error is
” A bug in a computer program in which the logic is faulty — for instance, in which instructions are not in proper sequence or the wrong instructions are used. ”
Examples :
Assume that NO syntax errors r there in the followings :
1.imagine u wanted to add two variables but instead of that u divided them by mistake !
2.imagine u have to first add THEN multiply but u reversed the order by mistake !
3.imagine that u were writing some code to convert the temperature from Celsius to Fahrenheit , but u mistyped the formula of conversion or used a wrong formula!
And too many examples u will find urself in programming course
These situations can occur and yet they r tricky to find . How t overcome them ?
Test, test, and test ur code !!!!! Make test programs to examine ur logic with sample data whose results u know 100% and keep trying until u -hopefully- find and fix the error.
a very simple and yet good example for a simple tester program :
Imagine u wrote a function in C that returns the addition of two numbers ; but instead of that it gives incorrect results ( like for 3 +4 it gives 6 instead of 7 )
then u have to test it .
Assume u wrote the function in this way :
int foo( int x, int y )
{
return x + x ; // i know it’s error , but assume u had a bad day and used x twice by mistake
}
Now write a tester function for this foo () :
From math u know that 3+4 should give 7, right ?
The tester :
main ()
{
int first = 3 ;
int second = 4 ;
int expected = 7 ; // 3 + 4
// here call the function we r testing
int actual = foo (3,4) ;
if (actual != expected ) puts (” ERROR in calling foo (); please check your logic ” ) ;
else puts(“Testing foo () passed “);
}
BUT please always make sure that u use correct data and that ur using correct values for the expected result !!!
good luck