Explain about link and definition section in C language

CServer Side ProgrammingProgramming

The link and definition sections are called as preprocessor directives. It gives instructions to the compiler to link function from the system library.

For example, the definition section defines all the symbolic constants.


For example,

#define PI 3.1415

The preprocessor directives must start with # symbol.

Without link definition the program will not execute for some compilers. It helps the compiler to link the predefined functions from system library.

Predefined Functions

The predefined functions present in stdio.h are as follows −

printf()Print the character, string, float, integer, octal onto the screen.
scanf()Read a character, string, numeric data from keyboard.
getc()Reads character from file.
gets()Reads line from keyboard.
getchar()Reads character from keyboard.
puts()Writes line to output screen.
putchar()Writes a character to screen.
clearerr()Clears the error indicators.
fopen()All file handling functions are defined in stdio.h header file.
fclose()Closes an opened file.
getw()Reads an integer from file.
putw()Writes an integer to file.
fgetc()Read a character from file.
putc()Write a character to file.
fputc()Write a character to file.
fgets()Read string from a file.
fputs()Write string to a file.
feof()Finds end of file.
fgetcharReads a character from keyboard.
fgetc()Reads a character from file.
fprintf()Writes formatted data to a file.
fscanf()Reads formatted data from a file.
fputcharWrites a character from keyboard.
putc()Writes a character to file.
sprint()Writes formatted output to string.
sscanf()Reads formatted input from a string.
remove()Deletes a file.
fflush()Flushes a file.


Following is the C Program to compute circumference of a circle

 Live Demo

#include <stdio.h>// link section
#define PI 3.1415 //definition section
main (){
   float c,r;
   printf("Enter radius of circle r=");
   printf("Circumference of circle c=%f", c);


The output is as follows −

Enter radius of circle r=6
Circumference of circle c=37.698002
Updated on 15-Mar-2021 10:19:23