Tuesday, May 26, 2020

Build-in String function in python

                      These all are the build-in function in python that can be used by any Python developers and learners, students, and other people too. These functions in python will help to improve the running time of any python program and save the time of any user to write the function to do small work like capitalize, split, find, and more.

 
 Build-in String function in python
 Build-in String function in python

Python String Function:- 

 capitalize() function in python: -  

capitalize() function in python used to convert the first letter of string into upper case.

 Syntax : -

string.capitalize() 

casefold() function in python: - 

casefold() is the same as the lower() function both function are used to convert characters into lower case,but casefold() function is more stronger then lower() methos it means casefold() function can convert more characters into lower case.

Syntax : -

string.casefold()

center() function :-

 center function in python used to align the string at the center using the specified character as the fill character.

Syntax : -

string.center(length, character)

Length is required because it is the length of returning the string.

The character used to fill the missing space on each side of the default string.

count() function :-

count() function in python programming helps to count the specified value appears in the string. You also have to tell about the start and endpoint for the count.

Syntax : -

string.count(value, start, end)

encode() function :-

count() function in python use to encode the string under the specified encoding if the encoding is not specified then UTF-8 will be used by default.

Syntax : -

string.encode(encoding=encoding, errors=errors)

'backslashreplace'    -  backslash  uses  when characters could not be encoded

'ignore'    - it will ignore the characters that cannot be encoded


'namereplace'    - a text explaining the character replace that character.


'strict'    - Default, raises an error on failure


'replace'    -  question mark will
replace the character

'xmlcharrefreplace'    - an xml character
will replace the character

endswith() in python :-

 endswith() in python returns true if given string will end with the specified value, otherwise False.

Syntax : -

string.endswith(value, start, end)

expandtabs() in python :-

 expandtabs() method in python set the tab size to the specified number of whitespaces.

Syntax : -

string.expandtabs(tabsize)

find() in python :-

find() function use to find the first occurrence for the given value. The find() function returns -1 if the value is not found.

Syntax : -

string.find(value, start, end)

index() in python:-

index() function is also used to find the first occurrence for the given value. The index() method raises an exception if the value is not found.

Syntax : -

string.index(value, start, end)

 Python string isalnum() method:-

isalnum()method in python returns true if all the characters are
alphanumeric, it means letter (a-z) and numbers (0-9).

Syntax : -

string.isalnum()

 Python string isalpha() function:-

isalpha()method in python returns true if all the given characters are alphabet letters (a-z).

Example for nonalphabet letters: -  !#%&? etc.

Syntax : -

string.isalpha() 

 Python string isdecimal() function:-

isdecimal() method is slightly different from other "is function in python" this method returns true if all the given characters are decimals (0-9).

Syntax : -

string.isdecimal() 

 isdigit() function:-

isdigit()method in python returns true if all the given characters are digits, otherwise False.

Syntax : -

string.isdigit()

isidentifier() function:- 

isidentifier() method gives the true if the string is a valid identifier, otherwise false, to check given string is valid identifier so string should contain alphanumeric letters (a-z) and (0-9), or underscores (_). A valid identifier can't be started with a number and space.

Syntax : -

string.isidentifier()

islower() function:- 

 This method returns true if all the string characters are in lower case otherwise false in python.

Syntax : -

string.islower()

isnumeric() function:- 

isnumeric() method returns true if all the string characters are in are numeric (0-9), otherwise false in python.

Syntax : -

string.isnumeric()

isprintable() function:- 

isprintable() method returns true if all the string characters are in are printable, otherwise false in python.

Syntax : -

string.isprintable()

isspace() function:-

isspace() function in python programming returns true if all the string characters are whitespaces, otherwise false in python.

Syntax : -

string.isspace()

istitle() function:- 

istitle() function follow the English language tradition because this function returns true if words in text start with upper case letter, AND end with the lower case letters, otherwise False.

Syntax : -

string.isspace()

join() function:-

join() function takes all the items to form an iterable and use to join them into one string

Syntax : -

string.join(iterable)

ljust() function:- 

ljust() function in python is used to align the text on the left side with the help of the specified characters (space is the default) as the fill character.

Syntax : -

string.ljust(length, character)

lower() function:- 

lower() function in python is used to return where all characters are lower case.

Syntax : -

string.lower()

lstrip() function in python:-

lstrip() method is used to neglect any leading characters in python string-like default leading characters to remove.

Syntax : -

string.lstrip(characters)

partition() function in python:- 

partition() function in python searched for specified string and splits given string into a tuple which contains three elements.
The first element contains the part before the specified string and the second one contains the specified string and the last one contains the part after the string.

Syntax : -

string.partition(value)

replace() method in python:-

replace() function method replaces all specified phrase with another specified phrase.

Syntax : -

string.replace(oldvalue, newvalue, count) 

rfind() in python :-

rfind() function used to find the last occurrence for the given value. The find() function returns -1 if the value is not found.

Syntax : -

string.rfind(value, start, end)

rindex() in python:-

rindex() function is also used to find the last occurrence for the given value. The index() method raises an exception if the value is not found.That's why rindex() is different from rfind() function in python.

Syntax : -

string.rindex(value, start, end)

rjust() in python:-

ljust() function in python is used to align the text on the right side with the help of the specified characters (space is the default) as the fill character.

Syntax : -

string.rjust(length, character)


rpartition() function in python:- 

rpartition() function in python searches last occurrence of a specified string and splits given string into a tuple which contains three elements.
The the first element contains the part before the specified string and the the second one contains the specified string and the last one contains the the part after the string.

Syntax : -

string.rpartition(value)

rstrip() function in python:-

rstrip() method is used to neglect any trailing characters in python like space is a default trailing character to remove.

Syntax : -

string.rstrip(characters)

split() method:-

As it name says split() function in python use to splits a string into a list.

Syntax : -

string.split(separator, maxsplit)


startwith() in python :-

 startwith() in python returns true if the given string will start with the specified value, otherwise False.

Syntax : -

string.startswith(value, start, end)

swapcase() in python :- 

 startwith() in python returns the string where all the upper case letters are converted into the lower case and vice versa.

Syntax : -

string.swapcase()

zfill() in python :- 

 zfill() method in python add zeros at the starting of the string until it reaches the specified length.

Syntax : -

string.zfill(len)

These all are the function in python which is used to manipulate the strings in python programs.

Sunday, May 24, 2020

Build-in function in python programming



learn about all the built-in functions in python and learn about their syntax and how to use them.

Build-in function in python programming
Build-in function in python programming

abs function in python:-

abs() function is also known as python absolute value function it's used to return the absolute value of the specified number.

Syntax : -

abs(n) 

all() function in python :-

abs() function in python return true if all elements of the iterable are true otherwise it return false.
 
all(iterable) 

any() function in python :-

any() function in python return true if all elements of the iterable are true If the iterable is empty, return False.

any(iterable) 

ascii() function in python :-

ASCII() function in python return a readable format of any object (Strings, Tuples, Lists, etc). It also replaces any non-ASCII characters with escape characters.

Syntax : - 

ascii(object) 

bin() function in python :-

bin() function in python programming is used to change any specified number into binary form and return that binary number to the calling function.

Syntax : - 

bin(n)

remember result will start with 0b prefix.

bool() function in python :-

bin() function in python programming return the boolean value of specified objects in the python program.
If the object is not true then it will be : - 

The object is empty, like [], (), {}
The object is False
The object is 0
The object is None


Syntax : - 

bool(object)

bytearray() function in python :-

bytearray() function in python programming uses to return the byte of object. It can convert objects into bytearray objects.

Syntax : -

bytearray(x, encoding, error)

X : - it is a source to create the bytearray().

Encoding: -  encode the string


Error:- Specified what to if any error occurs.


byte() function in python :-

 byte() function in python programming return a byte object and convert the object into byte object same as bytearray() function the only difference between byte and bytearray() function is that byte return an object that can not be modified and bytearray() function return an object that can be modified.

Syntax : - 

bytes(x, encoding, error)

byte() function in python :-

byte() function in python programming returns true if the specified object is callable or return false.

Syntax : - 

callable(object) 

chr() function in python programming:-

chr() function in python returns the character which is represented by the help of Unicode.

Syntax : - 

chr(number) 


compile() function in python :-

compile() function in python return the source as the code object which is ready to be executed or run.

Syntax : - 

compile(source,
    filename, mode, flag, dont_inherit, 
    optimize)
   

complex() function in python :-

the complex() function given a complex number that contains a real number and an imaginary number.

Syntax : -

complex(real, imaginary) 


delattr() function in python :-

delattr() function help you to delete the specified attribute from the specified object.

Syntax : -

delattr(object, attribute)
  

dict() function in python :-

dict() function help you to create the dictionary in python.

Syntax : -

delattr(object, attribute)
  
dict() doesn't return anything.


dir() function in python :-


dir() function in python returns the properties and methods of the specified object, without the values. it means dir() function will tell you what process should apply on the object.

Syntax : -

dir(object)
  
  
divmod() function in python :-

 

divmod() function in python

is used to return the
quotient and the remainder because argument1 (dividend) is divided by argument2 (divisor).

Syntax : -

divmod(divident, divisor)
   
 

enumerate() function in python :-

 enumerate() function in python takes a list of tuples and return it as an enumerate object.Its also used to add a counter to an iterable and give back in a form of enumerate object.

Syntax : -

enumerate(iterable, start)
 

eval

() function in python :-

eval() function in python use to validate the specified expression if the expression is legal Python statement, then it go further execution.

Syntax : -

eval(expression, globals, locals)
 

exec() function in python :-

 exec() function work as same as eval() function but only different is exec() execute a large blocks of code unlike the eval() function in python execute the single expression.

Syntax : -

exec(object, globals, locals)


filter() function in python :-

filter() function in python use to filters the given iterable(set which is going to be filter like list, tuples etc.) with the help of a function which test the every element in given iterable to be true or not.

Syntax : -

filter(function, iterable)
  

float() function :-

filter() function in python converts the given value into a floating point.

Syntax : -

float(value)


format() function :-

format() function in python given value into a specified format.

Syntax : -

format(value, 
    format)


froaenset() function for python :-

frozenset() function in python gives an unchangeable frozenset object which can be define by user.

Syntax : -

frozenset(iterable).
  

getattr() function for python :-

getattr() function in python gives the specified attribute from the specified object in python.

Syntax : -

getattr(object, attribute, default)
  

globals() function for python :-

globals() function in python programming gives a table of the symbol as a dictionary and that symbol table contains necessary information about the current program.

Syntax : -

globals()


hasattr() function for python :-

hasattr() will return true if the specified object in python gives the specified attribute otherwise gives false.

Syntax : -

hasattr(object, attribute)
  

hex() function for python :-

hex() function in python programming uses to convert the specified number into a hexadecimal number. 

Syntax : - 
hex(number)
  

id() function :-

id() function in python gives the unique id for a specified object and id is assigned to object at a time when the object is created.
Well id is a memory address for that specified object and it will be changed every time user run the python program

Syntax : -

id(object)

input() function

input() function in python use to give input to the python program.


Syntax : -

input(prompt)
  
 

int() function

int() function help to convert the specified number into an integer number.

Syntax : -

int(value, base)
python isinstance() function :-

isinstance() function gives true if the specified object is followed by the specified type otherwise false.


Syntax : -

isinstance(object, type)
 

python issubclass() function :-

issubclass() function gives true if the specified object is a subclass of a class object otherwise false.

Syntax : -

issubclass(object, subclass

subclass: - A class of objects.

python iter() function :-


Return the iterator object in python.

Syntax : -

iter(object, sentinel)


python len() function :-

len() function is very helpful to know about the number of items in an object.

Syntax : -

len(object)

python list() function :-

this function does the same as its name says list() function in python use to create an ordered and changeable list of objects.

Syntax : -

list(iterable)
  

python local() function:-

local() function in python returns a symbol table which contains all the necessary information about the python program. 

Syntax : -

locals()
   

map() function

map() function in python is a special function it executes the specified function for every item in iterable. The item is sent to the function as a parameter.

Syntax : -

map(function, iterables)
   

max() function:-

As its name says max() function gives the maximum value item from iterable.

Syntax : -

max(iterable)

memoryview () function:-

 memoryview() object gives a memory view object from a specified object.

Syntax : -

memoryview(obj

min() function:-

As its name says min() function gives the minimum value item within the given iterable.

Syntax : -

min(iterable)

next() function:-

As its name says next() function returns the next value form the given an iterator. Add a default value for the end of the iterable.

Syntax : -

next(iterable, default)

object() function:-


object function in python programming gives you a new object that object can't be changed or update with new properties  because it contains  built-in properties and methods that are default and for all classes.

Syntax : -

object()

oct() function in python:-


oct function in python programming helps to convert an integer into an octal string.

Syntax : -

oct(int)

open() function in python:-


open() function in python use to open a file and returns the file objects.

Syntax : -

open(file,mode)

ord() function in python:-

ord() function in python gives the number in Unicode which is used to representing the specified character. 

Syntax : -

ord(character)

pow() function in python:-

As its name says pow() function returns the value of x to the power of y (xy).if any third parameter is present then it takes as modulus in python.

Syntax : -

pow(x, y, z)

print() function in python:-

print() function is used to print the specified message to the screen and other output devices. The message can be any object.

Syntax : -

print(object(s), sep=separator, end=end, file=file, flush=flush)

range() function in python:-

range() function return the sequence of number which is started by default 0 and increase by 1 and stops before a specified number.

Syntax : -

range(start, stop, step)

reversed() function in python:-

reversed () function in python gives the reverse iteration object in python.

Syntax : -

reversed(sequence)

round() function in python:-

the round() function gives a floating-point number and that number is a rounded version of a specified number in python program. It means it gives the nearest integer number.

Syntax : -

round(number,digits)

set() function in python:-

the set() function used to create a set of objects and the item list in the set is unordered and it will appear in random order.

Syntax : -

set(iterable)

setattr() function in python:-

setattr() function in python programming set the specified attribute for the specified object.

Syntax : -

setattr(object, attribute, value)
  

slice() function in python:-

slice() function in python is used to slice a specified sequence and starting point and endpoint of slicing can also be specified. You can also specify the steps for the slicing process.

Syntax : -

slice(start, end, step)
  

sorted() function in python:-

sorted() function use for data structure in python this function used to sort the list of the specified iterable object. You can also define the ascending or descending order.

Syntax : -

sorted(iterable, key=key, reverse=reverse)  

str() function in python:-

str() function used to convert the specified value into a string.

Syntax : -

str(object, encoding=encoding, errors=errors)  

sum() function in python:-

sum() function returns the number which is the sum of all iterable in python.

Syntax : -

sum(iterable,  start)

super() function in python:-

  super() function in python is used to give access to all the properties and methods of parent and sibling classes.

Syntax : -

super()

tuple() function in python:-

tuple() function is used to creates the tuple object in python. 

Syntax : -

tuple(iterable)
  

type() function in python:- 

it will work as its name says type function in python programming helps to tell about the type of specified object.

Syntax : -

type(object, bases, dict)
  

vars() function in python:- 


vars() function is used to return the __dic__ attribute of an object.

__dic__ attribute containing the object's changeable attributes.

Syntax : -

vars(object)
  

zip() function in python:- 

zip() function in python will work like a zip file which means zip() in python return a zip() object which is a tuple of iterator so the first item in peach passed iterator is paired together, and the next one will do the same process.

if the passed iterator has a different length then the last item from the iterator decides the length of the new iterator.

Syntax : -

zip(iterator1, iterator2, iterator3 ...)
  
  
 these all are the Python Built-in Functions which used in python programs.

Saturday, May 23, 2020

Math function in c programming with examples

Note : - At first define math header file in a c program to access the all math function in c programming for example (sin(),cos(),tan(),pow(),sqrt()) and many more.

Math function in c programming with examples
Math function in c programming with examples

acos() function in c programming language : -

asoc () function in c programming helps to return the arc cosin value of element(x).

Synatx : -  

double acos(double x);

asoc () function in c will return the value between 0 and π.

 asoc() Example

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will find the acos of */
    value = 0.5;

    /* Calculate the Arc Cosine of value */
    result = acos(value);

    /* Display the result of the calculation */
    printf("The Arc Cosine of %f is %f\n", value, result);

    return 0;
}

 out put : -

Arc Cosine of 0.500000 is 1.047198

asin() function in c programming language : -

asin() function in c do the work same as asin() it helps you to return the arc sine value of element(x).

Synatx : - 

double asin(double x); 

asoc () function in c will return the value between -π/2 and π/2.

asin() Example

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will find the asin of */
    value = 0.5;

    /* Calculate the Arc Sine of value */
    result = asin(value);

    /* Display the result of the calculation */
    printf("The Arc Sine of %f is %f\n", value, result);

    return 0;
}

 out put : -

Arc Sine of 0.500000 is 0.523599

atan() function in c programming language : -

atan() function in c helps you to return the arc tengent value of element(x).

Synatx : - 

double atan(double x);

atan () function in c will return the value between -π/2 and π/2.

atan() Example

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will find the atan of */
    value = 0.5;

    /* Calculate the Arc Tangent of value */
    result = atan(value);

    /* Display result for calculation */
    printf("Arc Tangent of %f is %f\n", value, result);

    return 0;
}

 out put : -

Arc Tangent of 0.500000 is 0.463648

atan2() function in c programming language : -

atan2() function in c slightly different form tan2() because return the arc tengent value of element(x/y).

Synatx : - 

double atan2(double y, double x);

atan2() function in c will return the value between -π and π.

atan2() Example : - 

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value1, value2;
    double result;

    /* Assign the two values we will find the atan2 of */
    value1 = 0.5;
    value2 = -0.5;

    /* Calculate the Arc Tangent of value1 and value2 */
    result = atan2(value1, value2);

    /* Display the result of the calculation */
    printf("The Arc Tangent of %f and %f is %f\n", value1, value2, result);

    return 0;
}

 Output : -

Arc Tangent of 0.500000 and -0.500000 is 2.356194

ceil() function in c programming language : -

ceil() function in c to return the smallest integer that is greater than or equal to define value(x).

Synatx : -  

double ceil(double x);

ceil() function in c return the smallest integer that is greater than or equal to define value x

 Example for ceil(): -

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will find the ceil of */
    value = 1.6;

    /* Calculate the ceil of value */
    result = ceil(value);

    /* Display the result of the calculation */
    printf("The ceil of %f is %f\n", value, result);

    return 0;
}

 Output : -

ceil of 1.600000 is 2.000000

cos() function in c : -

cos() function in c return the cosine value of define value(x).

Synatx : - 

double cos(double x);

It returns the cosine value of x and measured in radians.
cos() example : -

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will find the cos of */
    value = 0.5;

    /* Calculate the Cosine of value */
    result = cos(value);

    /* Display the result of the calculation */
    printf("The Cosine of %f is %f\n", value, result);

    return 0;
}
 Out put  : - 
 
Cosine of 0.500000 is 0.877583

cosh() function in c programming: -

cosh() function in c return the hyperbolic cosine value of define value(x).

Synatx : - 

double cosh(double x);

 remember if magnitude of x is to large then it returns an error.

 Example cosh() : -

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will find the cosh of */
    value = 0.5;

    /* Calculate the Hyperbolic Cosine of value */
    result = cosh(value);

    /* Display the result of the calculation */
    printf("The Hyperbolic Cosine of %f is %f\n", value, result);

    return 0;
}

Output : -

The Hyperbolic Cosine of 0.500000 is 1.127626

exp() function in c programming: -

exp() function in c returns the e with raise the power x.

Synatx : -  

double exp(double x); 

 Example of exp() : -

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will find the exp of */
    value = 5;

    /* Calculate the exponential of the value */
    result = exp(value);

    /* Display the result of the calculation */
    printf("The Exponential of %f is %f\n", value, result);

    return 0;
}

Output : -

Exponential of 2.100000 is 8.166170
 

fabs() function in c programming: -

fabs function in c programming helps to return the absolute value of a floating poin.

Synatx : - 

double fabs(double x);

 Example of fabs() : -


#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will find the fabs of */
    value = -2.1;

    /* Calculate the absolute value of value */
    result = fabs(value);

    /* Display the result of the calculation */
    printf("The Absolute Value of %f is %f\n", value, result);

    return 0;
}

Output : -

Absolute Value of -2.100000 is 2.100000

floor() function in c programming: -

floor() function in c programming is same as ceil() function but the only different is floor function return the largest interger that is smaller than or equal to x.

Synatx : -  

double floor(double x);

 Example of floor() : -

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will find the floor of */
    value = 1.6;

    /* Calculate the floor of value */
    result = floor(value);

    /* Display the result of the calculation */
    printf("The floor of %f is %f\n", value, result);

    return 0;
}

 Output : -

floor of 1.600000 is 1.000000

fmod() function in c language: -

fmod() function in c returns the remainder value when x is divided by y.

Synatx : - 

double fmod(double x, double y);

 Example of fmod() : -

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value1, value2;
    double result;

    /* Assign the values we will find the fmod of */
    value1 = 1.6;
    value2 = 1.2;

    /* Calculate the remainder of value1 / value2 */
    result = fmod(value1, value2);

    /* Display the result of the calculation */
    printf("The fmod of %f and %f is %f\n", value1, value2, result);

    return 0;
}

 Output : -

fmod of 1.600000 and 1.200000 is 0.400000

frexp() function in c language: -

frexp() function in c programming will splites a floating-point value into a fraction and an exponent . Here fraction value is return by frexp function and exponent is stored by exp variable in c.

Synatx : - 

double frexp(double value, int *exp);

remember that fraction must be greater than or equal to 0.5 and less than 1. or it can be zero or must be equal to zero.

Examples of fexp() :-

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    int e;
    double f;

    /* Assign the value we will find the exp of */
    value = 1.5;

    /* Calculate the fraction and exponential of the value */
    f = frexp(value, &e);

    /* Display the result of the calculation */
    printf("The Fraction and Exponential of %f are %f and %d\n", value, f, e);

    return 0;
}

Output : -
 Fraction and Exponential of 1.500000 are 0.750000 and 1

idexp() function in c language: -

If you want to combine the fraction and an exponent into a floating-point value so idexp function in c is best for useing in c programming.

Synatx : -  

double ldexp(double fraction, int exp);

Examples of idexp() :-

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    int e;
    double result;

    /* Assign the value and exponential we will use to find the ldexp */
    value = 1.5;
    e = 2;

    /* Calculate the ldexp of the value and the exponential */
    result = ldexp(value, e);

    /* Display the result of the calculation */
    printf("The ldexp of %f with exponential %d is %f\n", value, e, result);

    return 0;
}

log() function in c programming language : -

log() function in c programming will help you in c program to find the logarithm value of x to the base of e.

Synatx : -

double log(double x);

Example of log()

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will calculate the log of */
    value = 1.5;

    /* Calculate the log of the value */
    result = log(value);

    /* Display the result of the calculation */
    printf("The Natural Logarithm of %f is %f\n", value, result);

    return 0;
}

 Output : -

Natural Logarithm of 1.500000 is 0.405465

log10() function in c programming: -

log10() function in c programming will help you in c program to find the logarithm value of x to the base of 10. This function same as like log() function the only different is log10() function return the value with base 10 not with e.

Synatx : -

double log10(double x);

Example of log10()

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will calculate the log10 of */
    value = 1.5;

    /* Calculate the log10 of the value */
    result = log10(value);

    /* Display the result of the calculation */
    printf("The Base 10 Logarithm of %f is %f\n", value, result);

    return 0;
}

 Output : -

Base 10 Logarithm of 1.500000 is 0.176091

log10() function in c programming: -

modf() function in c programming helps to splites floating point value into an integer and a fractional part. The fractional part return with modf() function in c programming and integer part is stored in the iptr variable

Synatx : - 

double modf(double value, double *iptr);

Example of modf()

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    double i, f;

    /* Assign the value we will calculate the modf of */
    value = 1.7;

    /* Calculate the modf of the value returning the fractional and integral parts */
    f = modf(value, &i);

    /* Display the result of the calculation */
    printf("The Integral and Fractional parts of %f are %f and %f\n", value, i, f);

    return 0;
}

 Output : - 

Integral and Fractional parts of 1.700000 are 1.000000 and 0.700000

    Some Common Function in c

 pow() function : -

 pow() function in c programming return the value of define element x which is raised to the power of y.

Synatx : -

double pow(double x, double y);

Example of pow()

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value1, value2;
    double result;

    /* Assign the values we will use for the pow calculation */
    value1 = 4;
    value2 = 2;

    /* Calculate the result of value1 raised to the power of value2 */
    result = pow(value1, value2);

    /* Display the result of the calculation */
    printf("%f raised to the power of %f is %f\n", value1, value2, result);

    return 0;
}

 sin() function : -

 sin() function in c programming returns the sine of defined value x.

Synatx : -

double sin(double x);

Example of sin()

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will find the sin of */
    value = 0.5;

    /* Calculate the Sine of value */
    result = sin(value);

    /* Display the result of the calculation */
    printf("The Sine of %f is %f\n", value, result);

    return 0;
}

 sinh() function : -

 sinh() function in c programming returns the hyperbolic sine of defined value x.

Synatx : -

double sinh(double x);

Example of sinh()

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will find the sinh of */
    value = 0.5;

    /* Calculate the Hyperbolic Sine of value */
    result = sinh(value);

    /* Display the result of the calculation */
    printf("The Hyperbolic Sine of %f is %f\n", value, result);

    return 0;
}

sqrt() function in c: -

sqrt() function in c programming return the square root of defined value x.

Synatx : -

double sqrt(double x);

Example of sqrt()

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will find the sqrt of */
    value = 25;

    /* Calculate the square root of value */
    result = sqrt(value);

    /* Display the result of the calculation */
    printf("The Square Root of %f is %f\n", value, result);

    return 0;
}

 

tan() function in c: -

tan() function in c programming return the tangent of defined value x.

Synatx : -

double tan(double x);

Example of  tan()

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will find the tan of */
    value = 0.5;

    /* Calculate the Tangent of value */
    result = tan(value);

    /* Display the result of the calculation */
    printf("The Tangent of %f is %f\n", value, result);

    return 0;
}

 

tanh() function in c: -

tanh() function in c programming return the hyperbolic tangent of defined value x.

Synatx : -

double tanh(double x);

Example of  tanh()

 

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[])
{
    /* Define temporary variables */
    double value;
    double result;

    /* Assign the value we will find the tanh of */
    value = 0.5;

    /* Calculate the Hyperbolic Tangent of value */
    result = tanh(value);

    /* Display the result of the calculation */
    printf("The Hyperbolic Tangent of %f is %f\n", value, result);

    return 0;
}

 these all are the math function in c programming languages which helps you to reduce the length of a c program and also save time in c programming.