Friday, May 21, 2010

C Programming Homework?

Hello. Can somebody help me with this homework in my computer class? I need to submit this tomorrow... Please help me answer these questions: 1. What is the simplest and largest cause of failure in all computer programs? 2. Differentiate syntax error from logical error. 3. Give the symbols used in C programming and their functions. 4. Differentiate Visual Basic from C Programming.





I hope somebody could help me answer at least one question. Many many thanks. :)

C Programming Homework?
1. It's uninitialized memory or so called dangling pointers. But the most dangerous is buffer overflow.


2. Syntax error is when you messed up syntax of the language like when you forget to add ; at the and of the statement. On the other hand logical is when you mess up your algorithm.For example when you want to process array of items and you forget that array is indexed from 0 to length - 1 and your loop looks like


for(i = 0; i %26lt;= LENGTH; i++) { ... }


3. I'm not quite sure if i understand the question but let's try


* - it can dereference pointer or it's multiplication - it depends on the tokens used.


%26amp; - get the address of the variable.


++ - pretty much inc instruction in the asm. So (i++) == (i = i + 1)


-- - same as ++ but for subtraction.


| - bitwise or


%26amp; - bitwise and


|| - logical or


%26amp;%26amp; - logical and


and many others like %26gt;%26gt; %26lt;%26lt; and so on ...


4. Visual basic is high level language used to create GUI application for MS Windows and C is language used for example to write operating systems , compilers and so on. C is harder to use but is more efficient and you have direct access to the hardware. Many of these statements are oversimplified but imo for some homework it's enough :)
Reply:1. The person has no clue what they are doing.


2. Syntax - No real answer. Thats like entering into a calculator: 3.3456.5.3 * 2.
Reply:1. not meeting requirements


2. syntax errors are compiler driven while logical errors are defects of logic.


4. Visual basic allows you to implement object-oriented methodology (includes object definition etc..)
Reply:1. Bad programming, not knowing whta you are doing.


2. Syntax errors won't compile, logical errors will, but produce results that aren't what you are expecting.


3. Another post will have these.


4. C is older, not visual. Visual Basic isn't as powerful, but is easier and more popular in industry.


No comments:

Post a Comment