Programming Articles - Page 2144 of 3366

const_cast in C++ - Type casting operators

Sunidhi Bansal
Updated on 20-Jan-2020 07:38:45

2K+ Views

Given the task is to show the working of const_cast in c++.const_cast is one of the type casting operators. It is used to change the constant value of any object or we can say it is used to remove the constant nature of any object.const_cast can be used in programs that have any object with some constant value which need to be changed occasionally at some point.SyntaxThe syntax is as follows −const_cast(expression)ExampleInput: const int x = 50; const int* y = &x; cout

clocale header file in C++

Sunidhi Bansal
Updated on 20-Jan-2020 07:33:16

291 Views

Given the task is to show the use of header file in C++.The header file is a part of the localization library which further is a part of the C++ standard library. Originally it was in the C standard library with the name as .The functions and declarations included in this header file are used for tasks that require date formats and currency symbols of different countries.The functions included in header file are setlocale() and localeconv()The macros that are defined in this header file and are used in these two functions are −LC_ALL-> It sets everything.LC_COLLATE-> It ... Read More

cosh() function for complex number working with C++

Sunidhi Bansal
Updated on 20-Jan-2020 07:32:37

165 Views

Given the task is to show the working of cosh() function for complex numbers in C++.The cosh() function is a part of the C++ standard template library. It is a little different from the standard cosh() function. Instead of calculating the hyperbolic cosines of angles that are in radians, it calculates the complex hyperbolic cosine values of complex numbers.The mathematical formula for calculating complex hyperbolic cosine is −cosh(z) = (e^(z) + e^(-z))/zWhere, “z” represents the complex number and “i” represents the iota.The complex number should be declared as follows −complex name(a, b)Here, that is attached to the “complex” data ... Read More

Cos() function for complex number in C++

Sunidhi Bansal
Updated on 20-Jan-2020 07:28:27

264 Views

Given the task is to show the working of cos() function for complex numbers in C++.The cos() function is a part of the C++ standard template library. It is a little different from the standard cos() function. Instead of calculating the cosine of simple integral or rational numbers, it calculates the complex cosine values of complex numbers.The mathematical formula for calculating complex cosine is −cos(z) = (e^(iz) + e^(-iz))/2where “z” represents the complex number and “i” represents iota.The complex number should be declared as follows −complex name(a, b)Here, that is attached to the “complex” data type describes an object ... Read More

Copysign() function in C++

Sunidhi Bansal
Updated on 20-Jan-2020 07:27:50

119 Views

Given the task is to show the working of copysign() in C++.The copysign() function is a part of the C++ standard template library. It takes two arguments and produces the result by combining the magnitude of the first value and the sign of the second value. or header file should be included to call this function.SyntaxThe syntax is as follows −copysign(x, y)ExampleInput: copysign(4, -5) Output: -4Explanation − The following example demonstrates how we can copy the sign of one value to the magnitude of another value. The sign of the second argument, that is “-“and the magnitude of the ... Read More

list emplace() function in C++ STL

Sunidhi Bansal
Updated on 20-Jan-2020 07:26:29

626 Views

Given is the task to show the working of list emplace() function in C++.The list::emplace() function is a part of the C++ standard template library. It is used to insert values inside a list at a specified position by the user. header file should be included to call this function.SyntaxList_Name.emplace(position, element)ParametersThis function takes two parameters −First is position, which represents the position at which the new element has to be placed and the second is value, which represents the element that has to be inserted inside the list at the position.Return ValueThe function returns an iterator that point at the ... Read More

List assign() function in C++ STL

Sunidhi Bansal
Updated on 20-Jan-2020 07:22:18

2K+ Views

Given is th e task to show the working of the assign() function in C++.The list::assign() function is a part of the C++ standard template library. It is used to assign the values to a list and also to copy values from one list to another. header file should be included to call this function.SyntaxThe syntax for assigning new values is as follows −List_Name.assign(size, value)SyntaxThe syntax for copying values from one list to another is as follows −First_List.assign(Second_List.begin(), Second_list.end())ParametersThe function takes two parameters −First is size, that represents the size of the list and the second one is value, which ... Read More

List crbegin() and crend() function in C++ STL

Sunidhi Bansal
Updated on 20-Jan-2020 07:20:41

141 Views

Given is the task to show the working of list crbegin() and crend() functions in C++.The list::crbegin() and list::crend() functions are a part of the C++ standard template library. header file should be included to call these functions.list::crbegin()This function returns the constant iterator which points to the end element of the list which will be the reverse beginning of the list. It can be used for Backtracking the list but it cannot change the values in the list which means crbegin() function can be used for iteration only.SyntaxList_Name.crbegin()ParametersThe function does not accept any parameter.Return ValueThe function returns a constant reverse ... Read More

list cbegin() and cend() functions in C++ STL

Sunidhi Bansal
Updated on 20-Jan-2020 07:19:07

147 Views

Given is the task to show the working of list::cbegin() and list::cend functions in C++.The list::cbegin() and list::cend() functions are a part of the C++ standard template library. header file should be included to call these functions.list::cbegin()This function returns the constant iterator which points to the beginning element of the list. It can be used to traverse the list but it cannot change the values in the list which means cbegin() function can be used for iteration only.SyntaxList_Name.cbegin();ParametersThe function does not accept any parameter.Return ValueThe function returns a constant iterator that point at the beginning element of the list.list::cend()This function ... Read More

list back() function in C++ STL

Sunidhi Bansal
Updated on 20-Jan-2020 07:15:40

264 Views

Given is the task to show the working of list back() function in c++.The list::back() function is a part of the C++ standard template library. It is used to display the last element of any list. header file should be included before calling this function.SyntaxList_Name.back();ParametersThe function does not accept any parameter.Return ValueThe function returns the value of the last element of the list.ExampleInput: Lt.assign(3, 10) Lt.back() Output: 10Explanation − The following example shows how we can find the last value of any list by using the back() function. The list Lt is assigned three elements, each with value 10 and ... Read More

Advertisements