140 likes | 279 Views
STANDARD LIBRARY FUNTION. NAME- SHREYA BHOWMiK CLASS- XI SEC- B ROLL- 10. INTRODUCTION.
E N D
STANDARD LIBRARY FUNTION NAME-SHREYA BHOWMiK CLASS-XISEC-B ROLL-10
INTRODUCTION Various function (that are not part of basic C++ language)that help perform I/O operations ,that can’t be directly performed using C++ basic statements, are stored together in form of library. these stored functions can be called and used for the desired operations. LIBRARY- A library is a collection of subprograms used to develop other programs and software. they are not independent programs, rather they are helper code used in other independent program. The C++ of functions store functions of same category under separate files known as header files.
stdio.h This header file defines types and macros needed for the standard I/O package and also defines the standard I/O predefined streams.the standard I/O function contained in stdio.h are given below:
string.h This header file declares several string manipulations and memory manipulation routines. the functions contained in string.h are :
math.h This header file declares for the math functions and math error handlers.
stdlib.h This header file declares several commonly used routines like conversion routines , search / sort routines , and other miscellaneous things.
iostream.h This header file declares the basic C++ streams routines.
iomanip.h This file declares the C++ streams I/O manipulators and contains macros for creating parameterized manipulators.
String and character related function In a standard implementation, the string function require the header file string.h to provide their prototype. The character functions use ctype.h as their header file.
CHARACTER FUNTION NOTE: -The type of all the arguments is int because internally al l the characters are processed numerically i.e, through their ASCII value.
STRING FUNCTION NOTE: - String must be included as header file.
There are two function random( ) and randomized( ), which are used for generating random numbers. Two other functions rand( ) and srand ( ) also perform similar task. GENERATING RANDOM NUMBERS IN C++ To generate random numbers we need to use rand( ) function that produces a random number in the range to RAND_MAX.the RAND_MAX is also defined in stdlib.h which gives us the maximum value returned by rand( ).if we want to generate different random numbers everytime , we use srand( ) function. The srand( ) function start or seeds the random-numbers generator from a point that depends on the value we pass to srand( ) as argument. Therefore to generate different random numbers everytime, we should seed the generator with a truly variable value such as system time. NOTE: - srand( ) should be involved just once prior to the loop and not everything before generating a random number through rand( ).
RANDOM AND RANDOMIZE random( ) and randomize( ) are two other macros of stdlib.h having similar function as rand( )& srand( ) respectively. random(num) generates a random number within range 0 to num-1,e.g., random(10) will generate random number within range 0-9. To generate a random within a specific no.within a specific range (L to U) through random( ),we need to change the use of random( ) to: random(U-L+1)+L therefore randomize( ) initializes/seeds the random number generator with a random number. NOTE: - to use randomize ( ),we should include include<Time.h> as randomize( ) internally implement a macro that calls time function of time.h. Eg. #include<iostream.h> #include<stdlib.h> void main() { randomize( ); int Num,Rndnum; cin>>Num; Rndnum=random(num)+7; for(int N=1;N<=Rndnum;N++) cout<<N<<” “; }