A program is a set of instructions to perform a specific task.
We need a translator to convert the English
like sentences in the program to binary code which the computer understands. The translators used are as below. i. Assembler ii. Compiler iii. Interpreter
ASSEMBLER, COMPILER and INTERPRETER 1. ASSEMBLER: As assembler translates the symbolic codes of a program in assembly language to machine language instructions. The translation is done in the ratio one is to one symbolic instruction to one machine code instruction. 2. COMPILER: They are translators which translate all the instructions of the program into machine code which ca be used again and again. The source code is the input to the compiler and object code the output to the compiler. They can also link the subroutines of the program 3. INTERPRETER: It helps the user to execute the source program just like a compiler. The only difference to compiler is that it reads the program line by line as compared to a compiler that reads the entire program, and generates the object code. STRUCTURE OF A C PROGRAM The C program contains a number of building blocks called functions. Each function performs a specific task independently. Main sections of a C program are i. Include Header File Section: C program depends on some header files for some function definitions that are used in the program. Each header has an extension .h. They are included in the beginning of a program using #include directive #include <stdio.h> #include <stdio.h> ii. Global Declaration: This section declares some variables that are used in more than one functions. These variables are called global variables. iii. Function Main(): Every program written in C must contain a main() and its executions starts at the beginning of this function. int main(void) This is a function definition of main(). Parenthesis followed by main tells the user that main() is a function. This function above tells us that the function takes no arguments and returns a value of type int. we can also write void main(void) This functions takes no arguments and returns nothing. It can also be written as void main(). {}