Question

1. (a) Describe five transformations a pre-processor would typically apply to source code. 5 marks) (b) Describe five differe
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. (a).Five Transformations a pre processor would typically apply to source code.

Transformation Global:

  • Replacing the comments with single lines.
  • Usage of back slash newline are avoided, but also does not change the meaning of the long lines.
  • Always defining macro names with their expansions.
  • For Example:
  • /* # define*/
  • /* pi =
  • //3.14
  • We can define this as
  • #define PI 3.14
  • as Global value

Transforming Header Files:

  • This contains declarations and macro definitions as a file that are shared between source files.
  • We can define the header file inside the program.
  • For Example:
  • in C program,#include followed by directive name is defined for including header file in source code.
  • Instead of defining the entre code, we can include  header file into the source code.

Defining Macros:

  • Macros are the sort abbrivation that is defined once in file which can be used later inside the source file.
  • for example:
  • #define BUFFER SIZE 2048
  • this defines the buffer size and allocates memory space globally which we can use any time in program.
  • There are many macro defining methods are there. For Example Predefined macros.

Stringification:

  • this is the process of making the fragment of code into constant.(i.e.)the content is
  • considered as text for the fragment.
  • for Example
  • an argument is defined as constant by
  • defining that content enclosed with double quotes.
  • 'banc(y)' is stringified by' "banc(x)" '.

Conditionals:

  • By applying conditions on the program, We can ignore the set of code form compilation.
  • This will increase the execution speed of the program.
  • For example: If statement is used with conditions which executes the code only if the the condition is true.

(b).Different ways in which the programmer can be noticed of compiler errors in source code.

  • We can define compiler error, if there is an error because of syntax in the programming language
  • As the programmer does not fulfill the general syntax of the programming language,Compiler error can occur.
  • Defining multiple variables with same name causes the compiler error.
  • Usage of non Predefined functions in the source code may cause Compiler error.
  • Therefore proper declaration and definition of functions inside the source code is used to eleminate the compiler errors.

(c).Steps to linking of libraries into programming source code and executable binary

  • First the we have to place the object file or executable file into the linker which links resulting in the binary file.
  • if the file is object file, it places into executable file and the file is being checked by the linker whether it has any referencing symbols or not, because it is not present in the previous libraries. in executable code.
  • if the two library has same symbol overriding occurs and and hence link does not occur smoothly.
  • Mentioning the libraries in the object files is fine, because in executable code there are dependencies may occur.
  • While defining static linking and dynamic linking of libraries. Shared (dynamic linkage is preferred because it does not have same library in multiple places.

(d).Notifying run time errors for  the programmers or end users to handle.

  • Run time errors occurs because of the unwanted event occurs during the run time of the program.
  • A programmer should know when will be the run time error occur in the program,
  • For example divide by zero is the run time error because it is undefined which cause termination of the program.
  • By finding run time  error we have to eliminate the error by using try catch block in higher level languages.
  • By handling the run time errors in the program we can eliminate the unwanted termination of the execution.
  • By handling the out of bound in array and is to be eliminated.
  • By maintaining the required memory space for the program to execute and is to be handled.

  

Add a comment
Know the answer?
Add Answer to:
1. (a) Describe five transformations a pre-processor would typically apply to source code. 5 marks) (b) Describe fi...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT