answersLogoWhite

0


Best Answer

when you compile your program , it is sequentially checking your coding and check whether there is an error. thats the simple thing happening. if there is no error, then it will create an executable file for your coding which is run when you ask to run the program after compiling. if your coding have an error, then you have to correct those errors. REMEMBER that it is compulsory to compile the program after you correct the errors. otherwise, it will not make an executable file with your corrections.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

Compiling means converting it to the for which machine can understand.

Infinity..

C++, COBOL, Pascal, BASIC, and other programming languages are English-like; a computer is an electro-magnetic machine that doesn't directly understand either English or English-like programming languages. In order for a computer to "execute" or "run" a program, the program must be translated into the electro-magnetic switches that the computer "understands." There are several ways of doing this, including assembling, interpreting, and compiling.

Assembly languages are formed by one English-like code for every instruction of the machine's native language, "machine code." Translation of a program written in an assembly language into machine code is called "assembling" the program. Because assembly language instructions map (via assembling) directly to machine instructions, the resulting machine code is likely to be extremely efficient -- runs fast and conserves memory. These are the primary advantages of assembly- language programming. Disadvantages: it tends to be hard to work with, and, since every model of computer has its own version of assembly language, programs aren't "portable" -- they must be rewritten in order to run on other models of computers. For example, a program written in IBM PC assembly language should run on all IBM PC-compatible computers, but not on Macintoshes.

"High-level languages" such as C++, COBOL, etc., tend to be easier for programmers to work with than assembly languages since an instruction in a high-level language typically is the equivalent of several assembly or machine language instructions. High-level language programs are generally either interpreted or compiled into machine code.

Many beginning students of college-level computer programming know BASIC (not Visual Basic), which is usually interpreted. When an interpreted program runs and control within the program reaches a given instruction (such as a LET statement), the interpreter translates the instruction into machine code and executes the corresponding machine instructions, then goes on to the next instruction of the program WITHOUT REMEMBERING the machine code it has just finished executing. Thus, if an instruction is repeated, it must be re-translated to machine code before it can be re-executed.

By contrast, COBOL and C++ are usually compiled. The compiler translates the program IN ITS ENTIRETY to machine code, and "remembers" all the machine code by saving it in an "executable" file, before the program is run. Thus, when the program is run, translation of source code instructions to machine code has been done in advance; repetition of a source code instruction does not require re-translation of the source code instruction to machine code; hence the program tends to run faster. On some computers where a language can be both compiled and interpreted, the compiled version will run enormously faster -- it's not unusual for the parts of the program not requiring input or output to require 1000 times as much time in the interpreted as in the compiled version.

OK, this clearly indicates that an important advantage of compiling as opposed to interpreting is speed of execution. What could a disadvantage of compiling be? Well, remember we said above that one high-level language instruction is typically equivalent to several machine code instructions. Suppose you are running a program in, say, BASIC, that has 500 BASIC instructions, the average of which is equivalent to 5 machine code instructions and the largest of which is equivalent to 10 machine code instructions. If compiled, this would mean you would need enough memory to hold 5*500 = 2500 machine code instructions in order to run the program; if interpreted, you need enough memory to hold 500 BASIC instructions plus at most 10 machine code instructions (for whatever BASIC instruction is currently executing). Thus, interpreting uses less memory. This was an extremely important factor for the early microcomputers -- machines with small memories -- and probably explains why they typically came equipped with interpreted BASIC.

A compiler typically scans your source code file for "syntax errors," i.e., errors in the use of the programming language's rules concerning formation of statements in the program. Frequently, one actual error will generate several error messages, as the first error may "confuse" the poor compiler. Hence, the first error message is significant; others may or may not be.

If the compiler does not find "serious" syntax errors in your program, it will also typically (the details differ from one compiler to another) produce a file that is either the "executable" version of your program or an almost-executable (it may be an "object" file that must be "linked" to produce an executable file). The executable file is the machine code translation of your source code that the computer uses to execute your program when you give the command to do so. Students should note that the goal of the process is not merely to have your program run. It should run correctly and well. It may be necessary for you to observe your program's behavior, edit its source code, compile again, and run again, many times, before you are satisfied with your program's performance.

On the other hand, if the compiler finds errors in your program, it is necessary for you to edit these errors out of your program (in the editor). You must then re-compile. The cycle of editing and compiling may have to be repeated several times before your program is ready to run. Notice also that you're probably not "done" when your program runs the first time - successful compiling does not guarantee either correct logic (necessary to get correct "answers") or nice input/output. It's the programmer's responsibility to check these matters.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

1) Compiling: It is a build program that are executed during the compilation of a program. At compiling time the program are contagiously Scan for any syntax and semantics error. After compilation the txt file convert into ".obj"(object) file and linking part will be execute.

2) Linking: After compiling the Header file and related another files are attach with compiled program file and creates A lot of link betwixt function and there related header file it's called linking.

3) Execution: At the end of compilation and linking part the program really prepare to executed for use where in this part ''.obj'' file convert in to ''.exe" file it's called execution of a program.

So At first-compiling & linking then Execution of a program. And in file concept- a.txt>a.obj>a.bac>a.exe (say "a" is a program name)

*Here .bac is for backup file concept. After some changed in your save program the backup concept carry your previouse text program and save with the extention name .bac.

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

A compiled program is source code that is translated to either machine code (native code) or byte code. Native machine code requires no further translation and can be executed as-is, but byte code must be interpreted in order to produce the required machine code. Java is an example of a language that compiles to byte code that is suitable for interpretation by the Java virtual machine. C++, on the other hand, compiles to native machine code. Interpretation is much slower than executing native machine code program, however it is more efficient to interpret compiled byte code than it is to interpret high-level source code. Moreover, byte code is generally portable whereas native machine code is always machine-dependent.

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

No. Compilation only guarantees that each translation unit obeys the syntax and grammar of the language. It does not guarantee that those compiled units will be linked successfully. Even if linking is successful, this can only guarantee the program is able to execute but it does not guarantee it will execute correctly. For example, runtime errors are logic errors that were not detected at compile time. We can certainly enlist the compiler to help us detect some logic errors through the use of static assertions and compile time processing, but it is impossible to detect every type of logic error. This is why we must use exhaustive runtime testing after successful compilation and linking. Nevertheless, the compiler can help us to substantially reduce the amount of runtime tests we must perform but it cannot guarantee an error-free executable.

This answer is:
User Avatar

User Avatar

Wiki User

6y ago

It depends upon the machine architecture and whether the program is encoded in native machine code or requires further translation to produce the required machine code.

With native code, the operating system's program loader typically decodes the executable, allocating separate memory regions to cater for the program's text segment (the actual machine code), the data segment (static memory) and a call-stack for the main thread (additional call-stacks are allocated at runtime as and when required by any additional threads). The data segment is divided into two sections, an initialised section and an uninitialised section. The initialised section is usually stored as a bitmap within the executable file and is simply loaded directly into memory as-is. The uninitialised section makes up the remainder of static memory and is typically zero-initialised. The text segment can refer to any value in the data segment using the value's offset memory address which was established at link time. Once the execution environment is fully established, control is passed to the machine code which typically pushes the global main function onto the call stack and passes control to the first instruction. When the global main function ends, the program terminates and all memory allocations are released, including all memory allocated by the program at runtime.

With non-native code, a runtime interpreter is required to perform the translation from the compiled or high-level source code to native machine code. For instance, Java source code compiles to Java byte code which is suitable for interpretation by the Java virtual machine (JVM). The JVM is a native machine code program like any other and the JVM creates and manages the execution environment for the Java byte code.

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

A compiler takes the source code and generates an executable (the compiled program) that your device can run.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What happens when a program is compiled?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you use compiled in proverb?

The program compiled itself to give the correct result.


What is a compiled program that runs on the client inside of an interpreted program?

As far as I know, interpreted software does not run compiled software at all.


What is java virtucal mechine?

That refers to the program that runs the compiled Java program.


Which variable is initialized once when program is compiled?

global and static


Why are comments not compiled in a computer program?

'cos' they are just comments.


What is the use of macro date?

it returns the date your program was compiled in a string


What type of error is detected when a pascal program is compiled?

syntax error


What is a compiled program that runs on the client?

The program that runs on the client computer is the client program. Web-browser is a prominent example for client program.


How program can be complied in c?

C programs can be compiled with a C compiler. Are you surprised?


How is a C program compiled?

With a compiler. Read the documentation for programming package for help on how to.


How do you run a C program on SunOS?

A "C" program has to be compiled to machine code on any Unix system, whether it is Solaris or some other version. After compiling the program, execute it by typing in the name of the compiled program created by the "C" compiler. The standard name is 'a.out', but it could be named anything you want.


What is meant by flow of execution a program?

That means to load a computer program into a computer's memory, and have the computer carry out the instructions in the program.