Types of Functions:-
1. Library Functions: –
Functions defined previously in the library are called as library functions.
#include<math.h>
main( )
{
int n , p, ans;
printf(“Enter number and its power”);
scanf(“%d%d”,&n,&p);
ans = pow(n,p);
printf(“%d”,ans);
getch( );
}
Common Library Functions:
stdio.h functions
fclose( ) : Closes a stream
fcloseall( ) : Closes all open streams
feof( ) : Tests if end-of-file has been reached on a stream
fflush( ) : Flushes a stream
fgetc( ) : Gets a character from a stream
fgetpos( ) : Gets the current file pointer position
fsetpos( ) : Positions the file pointer of a stream
fgetchar( ) : Gets a character from stdin
fgets( ) : Gets a string from a stream
fopen( ) : Opens a stream
fprintf( ) : Send formatted output to stream
fputc( ) : Outputs a character to a stream
fputs( ) : Outputs a string to a stream
fread( ) : Reads data from a stream
fscanf( ) : Scans and formats input from a stream
fseek( ) : Sets the file pointer to a particular position
ftell( ) : Returns the current position of the file pointer
fwrite( ) : Writes to a stream
getc( ) : gets one character
getchar( ) : gets a character from stdin
gets( ) : Get a string from stdin
getw( ) : gets an integer from stream
printf( ) : Send the formatted output to stdin
putc( ) : Outputs a character to stdout
putchar( ) : Outputs a character on stdout
puts( ) : Outputs string and appends a newline character
putw( ) : Outputs an integer on a stream
remove( ) : Removes a file
rename( ) : Renames a file
rewind( ) : Brings the file pointer to stream’s beginning
scanf( ) : Scans and formats input from stdin
conio.h
clrscr( ) : Clears text mode window
getch( ) : gets a character from console but does not echo to the screen
getche( ) : gets a character from console, and echoes to the screen
putch( ) : Outputs character to the text window on the screen
cgets( ) : Reads string from console
getchar( ) : Inputs a character from stdin
stdlib.h
itoa( ) : converts an integer to a string
atoi( ) : Converts string of digits to integer
Random( ) : Returns a random number between 0 and number -1
randomize( ) : Initializes random number generator
exit( ) : Terminates the program
min( ) : Returns the smallest of two numbers
max( ) : Returns the largest of two numbers
Itoa( ) : converts a long to a string
ultoa( ) : converts an unsigned long to a string
atof( ) : converts a string to a floating point
atold( ) : converts a string to a long double
math.h
abs( ) : gets the absolute value of an integer
acos( ) : Calculates the inverse of cos Accepts the angle value in radians
asin( ) : Calculates the inverse of sin Accepts the angle value in radians
atan( ) : Calculates the inverse of tan Accepts the angle value in radians
ceil( ) : Returns the largest integer in given list
cos( ) : Calculates the cosine Accepts the angle value in radians
cosh( ) : Accepts the angle value in radians
exp( ) : Calculates the exponent
floor( ) : Returns the smallest integer in given list
log( ) : Calculates the natural logarithm
log 10( ) : Calculates the log of base 10
pow( ) : Calculates the power of a number
sin( ) : Calculates the sine value of an angle. Accepts the angle value in radians
sqrt( ) : Calculates the square root of a number
tan( ) : Calculates the tangent value of an angle. Accepts the angle value in radians
tanh( ) : Calculates the tangent hyperbolic value
string.h
strcat( ) : Function to concatenate(merge) strings
strcmp( ) : Function to compare two strings
strcpy( ) : Function to copy a string to another string
stricmp( ) : Function to compare two strings ignoring their case
strlen( ) : Function to calculate the length of the string
strlwr( ) : Converts the given string to lowercase
strrev( ) : Function to reverse the given string
strupr( ) : Converts the given string to uppercase
strdup( ) : Duplicates a string
strnicmp( ) : Compares the first n characters of one string to another without being case sensitive
strncat( ) : Adds the first n characters at the end of second string
strncpy( ) : Copies the first n characters of a string into another
strchr( ) : Finds the first occurrence of the character
strrchr( ) : Finds the last occurrence of the character
strstr( ) : Finds the first occurrence of string into another string
strset( ) : Sets all the characters of the string to a given character
strnset( ) : Sets first n characters of the string to a given character