GET EDUCATE

Contents
Basics of C Programming

⯈Basic C Programs

Header files in C

  • Header files have collection of functions in it. The header files are used so that the code can be reused across the programs.
  • Header files have extension of .h
  • The header files are written in link section of the C program.
  • The header files can be built-in, provided by the compiler or can be user-defined.
  • We include header files in our program using #include.
#include<stdio.h>
#include<math.h>
#include"stdlib.h"
  • We can write the header files either in angle brackets or in double quotations. 
  • If we write the header files in angle bracket, it will search only in the system folder (where compiler is installed)
  • If we write in double quotations first it will search in current folder, where the C program is written, if not found then it will search in system folder.

Some commonly used header files

stdio.h

std is standard, i is input and o is output.

All the input-output functions like printf, scanf, sprintf, gets, puts, getchar, putchar are defined in stdio.h

So, if we want to use any of the input-output functions in our program we need to include stdio.h

math.h

All the mathematical functions like sin, cos, tan, ceil, floor, etc.,are defined in math.h

So, if we want to use any mathematical functions in our program we need to include math.h

stdlib.h

Stands for standard library.

This header file includes exit function, all dynamic memory allocation functions like malloc, realloc, calloc and free.

limits.h

This header file contains all the MACROS that define the lower-range and upper-range of the int and char datatype.

MACRO Value Description
INT_MAX
2147483647
The maximum value that the int data type can store.
INT_MIN
-2147483648
The minimum value that the integer can store.
UINT_MAX
4294967295
The maximum value that the unsigned int can store.
(The minimum value is 0)
LONG_MAX
9223372036854775807
Maximum value that long int can store
LONG_MIN
-9223372036854775808
Minimum value that long int can store

string.h

All the string functionalities like strcpy, strlen etc., are defined in string.h

Scroll to Top