× Home stdio.h int main() printf() scanf() return 0 //coment steps taken by compiler
Next Lec → ← Previous Lec

Basic Structure of C Program

Some structural part of the code

Code

                    

                        #include <stdio.h>
                            int main()
                            {
                              int a, b;
                              printf("Enter no. a\n");
                              scanf("%d", &a);
                            
                              printf("Enter no. b\n");
                              scanf("%d, &b");
                            
                              printf("The sum is %d\n"; a+b);
                            return 0;
                            } 
                    
                

<stdio.h>

int main()

int a, b;

printf("Enter no. a\n")

scanf("%d", &a);

return 0;

//This is a comment

The steps which are taken by compiler to compile a program

Preprocessing → compilation → assembly → linking

1- Preprocessing → Here the comments are removed from the program.
all the #include files which are written in a program there content are placed in separate file
→ macros expand
→ the preprocessed output is stored in '.i' file


2- Compilation → '.i' file is converted into assembly instruction and saved as '.s' extension


3- Assembly → '.i' file where assembly language is written should be converted into machine level instruction so that CPU can understand, '.o' extension file can't be opened.


4- Linking → All the assembly files are sumed up and made into a executable file.