23-08 ch-1
23-08 ch-1
Basic Structure of c
• The basic structure of a C program is divided
into 6 parts.
1. Documentation
2. Pre-processor Section
3. Definition
4. Global Declaration
5. Main() Function
6. Sub Programs
1. Documentation
• This section consists of the description of the
program, the name of the program, and the
creation date and time of the program. It is
specified at the start of the program in the
form of comments. Documentation can be
represented as:
// description, name of the program,
programmer name, date, time etc.
#define a = 2
• Whenever this name is encountered by the
compiler, it is replaced by the actual piece of
defined code.
4. Global Declaration
// main function -
// where the execution of program begins
void main()
{
}
C library functions
• Library functions are built-in functions that are
grouped together and placed in a common
location called library.
• Each function here performs a specific
operation. We can use this library functions to
get the pre-defined output.
• All C standard library functions are declared by
using many header files.
• These library functions are created at the time
of designing the compilers.
Header File Functions
• stdio.h − It is a standard i/o header file in which
Input/output functions are declared
• conio.h − This is a console input/output header
file.
• string.h − All string related functions are in this
header file.
• stdlib.h − This file contains common functions
which are used in the C programs.
• math.h − All functions related to mathematics
are in this header file.
• time.h − This file contains time and clock related
functions.Built functions in stdio.h
Built functions in stdio.h
Sl.No Function & Description
1 printf()
This function is used to print the all char, int, float, string etc., values onto the output screen.
2 scanf()
This function is used to read data from keyboard.
3 getc()
It reads character from file.
4 gets()
It reads line from keyboard.
5 getchar()
It reads character from keyboard.
6 puts()
It writes line to o/p screen.
7 putchar()
It writes a character to screen.
8 fopen()
All file handling functions are defined in stdio.h header file.
9 fclose()
Closes an opened file.
10 getw()
Reads an integer from file.
11 putw()
Writes an integer to file.
12 fgetc()
Reads a character from file.
13 putc()
Writes a character to file.
14 fputc()
Writes a character to file.
LIST OF INBUILT C FUNCTIONS IN
CONIO.H
Functions Description