Friday, November 4, 2016

C Language Standard Library functions for BCA , BSc(IT) and PGDCA



Prepared By : Uday Shah - HOD (IT)
Contact No : 7600044051

--------------------------------------------------------------------------------------------------------------------------

abs()
The C library function int abs(int x) returns the absolute value of int x. Following is the declaration for abs() function.
int abs(int x)
x  is the integral value. This function returns the absolute value of x.

atof()
The C library function double atof(const char *str) converts the string argument str to a floating-point number (type double). Following is the declaration for atof() function.
double atof(const char *str)
str  is the string having the representation of a floating-point number. This function returns the converted floating point number as a double value. If no valid conversion could be performed, it returns zero (0.0).

atol()
The C library function long int atol(const char *str) converts the string argument str to a long integer (type long int). Following is the declaration for atol() function.
long int atol(const char *str)
str  is the string containing the representation of an integral number. This function returns the converted integral number as a long int. If no valid conversion could be performed, it returns zero.



exit()
The C library function void exit(int status) terminates the calling process immediately. Following is the declaration for exit() function.
void exit(int status)
status  is the status value returned to the parent process. This function does not return any value.

free()

The C library function void free(void *ptr) deallocates the memory previously allocated by a call to calloc, malloc, or realloc. Following is the declaration for free() function.
void free(void *ptr)
ptr  is the pointer to a memory block previously allocated with malloc, calloc or realloc to be deallocated. If a null pointer is passed as argument, no action occurs. This function does not return any value.
rand()
The C library function int rand(void) returns a pseudo-random number in the range of 0 to RAND_MAX. RAND_MAX is a constant whose default value may vary between implementations but it is granted to be at least 32767. Following is the declaration for rand() function.
int rand(void)
This function returns an integer value between 0 and RAND_MAX.

Strtoul()
The C library function unsigned long int strtoul(const char *str, char **endptr, int base) function converts the initial part of the string in str to an unsigned long int value according to the given base, which must be between 2 and 36 inclusive, or be the special value 0. Following is the declaration for strtoul() function.
unsigned long int strtoul(const char *str, char **endptr, int base)
str  is the string containing the representation of an unsigned integral number. endptr  is the reference to an object of type char*, whose value is set by the function to the next character in str after the numerical value. base  is the base, which must be between 2 and 36 inclusive, or be the special value 0.
This function returns the converted integral number as a long int value. If no valid conversion could be performed, a zero value is returned.

srand()
The C library function void srand(unsigned int seed) seeds the random number generator used by the function rand. Following is the declaration for srand() function.
void srand(unsigned int seed)
seed  is an integer value to be used as seed by the pseudo-random number generator algorithm. This function does not return any value.


labs()
The C library function long int labs(long int x) returns the absolute value ofx. Following is the declaration for labs() function.
long int labs(long int x)
x  is the integral value. This function returns the absolute value of x.

qsort()
The C library function void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*)) sorts an array. Following is the declaration for qsort() function.
void qsort(void *base, size_t nitems, size_t size, int (*compar)(const void *, const void*))
 


base  is the pointer to the first element of the array to be sorted. nitems  is the number of elements in the array pointed by base size  is the size in bytes of each element in the array. compar  is the function that compares two elements. This function does not return any value.

:: Best Of Luck :: 

Please give your comment and share it... Thank you