header files of c++ unit 3 -topic 3

18
Header Files of C++ Header files contain definitions of Functions and Variables, which is imported or used into any C++ program by using the pre-processor #include statement. Header file have an extension ".h" which contains C++ function declaration and macro definition. Why need of header files When we want to use any function in our C++ program then first we need to import their definition from C++ library, for importing their declaration and definition we need to include header file in program by using #include.

Upload: mohit-tomar

Post on 14-Apr-2017

167 views

Category:

Education


2 download

TRANSCRIPT

Page 1: Header files of c++ unit 3 -topic 3

Header Files of C++Header files contain definitions of Functions and Variables, which is imported or used into any C++ program by using the pre-processor #include statement. Header file have an extension ".h" which contains C++ function declaration and macro definition.

Why need of header filesWhen we want to use any function in our C++ program then first we need to import their definition from C++

library, for importing their declaration and definition we need to include header file in program by using

#include.

Page 2: Header files of c++ unit 3 -topic 3

Stdio.hInput and Output operations can also be performed in C++ using the C Standard Input and Output Library (cstdio, known as stdio.h in the C language). When you include iostream.h file in your program ,this file i.e, stdio.h automatically gets included in your program.

Page 3: Header files of c++ unit 3 -topic 3

<iostream.h>

• Standard Input / Output Streams Library.• Cin Standard input stream (object ) • Cout Standard output stream (object )

Page 4: Header files of c++ unit 3 -topic 3

<conio.h>• conio.h header used in c programming contains

functions for console input/output.• console is a term used for the black window, which

is also called as command prompt.• Some of the most commonly used functions of

conio.h are clrscr, getch,etc.

Page 5: Header files of c++ unit 3 -topic 3

<iomanip.h>• This file declares services useful for performing

formatted I/O with so-called parameterized stream manipulators, such as setw and setprecision.

• setprecision -Sets the decimal precision to be used to format floating-point values on output operations.

• Setw- Sets the field width to be used on output operations.

• The operator used for taking the input is known as the extraction or get from operator (>>), while the operator used for displaying the output is known as the insertion or put to operator (<<).

Page 6: Header files of c++ unit 3 -topic 3

Example of setprecision

Page 7: Header files of c++ unit 3 -topic 3

Example of setw

Page 8: Header files of c++ unit 3 -topic 3

Stringh.h

Page 9: Header files of c++ unit 3 -topic 3
Page 10: Header files of c++ unit 3 -topic 3
Page 11: Header files of c++ unit 3 -topic 3
Page 12: Header files of c++ unit 3 -topic 3

<math.h>• Most of the mathematical functions are

defined in math.h ( cmath header in C++).• The functions that operate on integers, such

as abs , labs , div , and ldiv , are instead defined in the stdlib.h header ( cstdlib header in C++).

Page 13: Header files of c++ unit 3 -topic 3
Page 14: Header files of c++ unit 3 -topic 3
Page 15: Header files of c++ unit 3 -topic 3

<stdlib.h>• This header defines several general purpose

functions, including dynamic memory management, random number generation, communication with the environment, integer arithmetics, searching, sorting and converting.

Page 16: Header files of c++ unit 3 -topic 3
Page 17: Header files of c++ unit 3 -topic 3

rand

Page 18: Header files of c++ unit 3 -topic 3