

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are the 4 steps to convert C program to Machine code?
Process of Creating and Running Programs
A program contains a set of instructions which was written in a programming language.
The programmer’s job is to write and test the program.
The 4 steps to convert a ‘C’ program into machine language are &miuns;
- Writing and editing the program
- Compiling the program
- Linking the program
- Executing the program
Writing and editing the program
‘Text editors’ are used to write programs.
With the help of text editors, users can enter, change and store character data.
All special text editors are often included with a compiler.
After writing the program, the file is saved to disk.
It is known as ‘source file’.
This file is input to the compiler.
Compiling the program
“Compiler” is a software that translates the source program into machine language.
The ‘C’ compiler is divided into two separate programs.
- Preprocessor
- Translator
Let us first see about Preprocessor −
Preprocessor
Preprocessor reads the source code and then prepares it for translator.
Preprocessor commands start with ‘#’ symbol.
They tell the preprocessor to look for special code libraries and make substitutions.
The result of preprocessing is known as ‘translation’ unit.
Translator
Translator’s work is to convert the program into machine language.
It reads the translation unit and results in ‘object module’.
But it is not completely executable file because it does not have the ‘C’ and other functions included.
Linking programs
‘Linker’ assembles I/O functions, some library functions and the functions that are part of source program into final executable program.
Executing Programs
‘Loader’ is the software that is ready for program execution into the memory.
In the process of execution, the program reads the data from the user, processes the data and prepares the output.
Example1
Following example is to find the average of 3 numbers −
#include<stdio.h> int main(){ int a,b,c,d; //declaring 4 variables float e; printf("Enter values of a,b,c:"); scanf("%d,%d,%d",&a,&b,&c); //read 3 input values from keyboard d=a+b+c; e=d/3; printf("Average=%f",e); // printing the result return 0; }
Output
Enter values of a,b,c :2,4,5 Average=3.000000
Example2
The following is to compute circumference of a circle −
#include <stdio.h> #define PI 3.1415 // defining PI value main (){ float c,r; printf("Enter radius of circle r="); scanf("%f",&r); c=2*PI*r; printf("Circumference of circle c=%f", c); }
Output
Enter radius of circle r=5.6 Circumference of circle c=35.184799
- Related Questions & Answers
- Convert C/C++ program to Preprocessor code
- What are the different steps involved to execute a Java program?
- C++ code to count steps to reach final position by robot
- Convert C/C++ code to assembly language
- Java Program to convert ASCII code to String
- 8086 program to convert binary to Grey code
- Python Program to Convert Gray Code to Binary
- Python Program to Convert Binary to Gray Code
- What are the steps to rename a file in Git?
- What are the steps involved to use a CURSOR in any COBOL-DB2 program?
- Minimum steps to make all the elements of the array divisible by 4 in C++
- What are the Classifications of Machine Learning?
- What are the applications of Machine Learning?
- What are the steps to execute Flow API in Java 9?
- 8085 code to convert binary number to ASCII code