2. WHAT IS A HEADER FILE
Header file included at the top of any
C program.
Syntax: #include <file>
All the header file have a '.h' an
extension that contains C function
declaration
Header files are imported into C
program with the help of pre-
processor #include statement
3. VARIOUS SYSTEM HEADER FILES
name discription
<stdio.h> Input/Output Functions
<conio.h> console input/output
<math.h> Mathematics Functions
<time.h> Date and Time Functions
<string.h> String Functions
<stdlib.h> General Utility Functions
<complex.h> A set of function for manipulating complex
numbers
<ctype.h> Character handling functions
<assert.h> Diagnostics Functions
4. The C programming language provides many standard
library functions for file input and output.
<stdio.h> functions
function discription
Printf() This function is used to print the
character, string, float, integer, octal
and hexadecimal values onto the output
screen
Scanf() This function is used to read a character,
string, numeric data from keyboard.
Fopen() Opens a file
Fclose() Close an opened file
Gets() It reads line from keyboard
5. conio.h header used in C programming contains
functions for console input/output
<conio.h> functions
function discription
Clrscr() This function is used to clear the
output screen.
Getch() It reads character from keyboard
Getche() It reads character from keyboard
and echoes to o/p screen
Textcolor() This function is used to change the
text color
Textbackground() This function is used to change text
background
6. Example of printf() ,scanf() ,getch() and clrscr ()
functions.
#include <stdio.h>
#include <conio.h>
int main()
{
int num1, num2, sum;
clrscr();
printf("Enter any two numbers : n");
scanf("%d%d", &num1, &num2);
sum = num1 + num2;
printf("Sum = %d",sum);
getch();
return 0;
}
7. math.h header file supports all the mathematical
related functions in C language.
<math.h> functions
Function Discription
Pow() This is used to find the power of the given number.
Sqrt() This function is used to find square root of the
argument passed to this function.
Log() This function is used to calculates natural logarithm.
Exp() This function is used to calculate the exponential “e”
to the xth power.
Log10() This function is used to calculates base 10 logarithm.
Floor() This function returns the nearest integer which is less
than or equal to the argument passed to this function.
8. Example of math.h
#include <stdio.h>
#include <math.h>
int main ()
{
printf("Value 8.0 ^ 3 = %lfn", pow(8.0, 3));
printf("Value 3.05 ^ 1.98 = %lf", pow(3.05, 1.98));
return(0);
}
9. Time functions in C are used to interact with system
time routine and formatted time outputs are
displayed
.
<time.h> functions
function discription
Getdate() This function is used to get the CPU time
Setdate() This function used to modify the system
date
Clock() This function is used to get current
system time
Time() This function is used to get current
system time as structure
10. Example program for<time.h>
#include<stdio.h>
#include<time.h>
#include<dos.h>
int main()
{
struct date dt;
getdate(&dt);
printf("Operating system's current date is %d-%d-
%dn",dt.da_day,dt.da_mon,dt.da_year);
return 0;
}
11. , C supports a large number of string handling
functions in the standard library "string.h".
<string.h> functions
function discription
Strlen() Calculates the length of string
Strcpy() Copies a string to another string
Strcmp() Concatenates(joins) two strings
Strcat() Compares two string
Strlwr() Converts string to lowercase
Strupr() Converts string to uppercase
12. Example of strncat:
#include <stdio.h>
#include <string.h>
int main()
{
char s1[10] = "Hello";
char s2[10] = "World";
strncat(s1,s2, 3);
printf("Concatenation using strncat: %s", s1);
return 0;
}