Found 7347 Articles for C++

forward list::cend() in C++ STL

Sunidhi Bansal
Updated on 20-Jan-2020 10:06:48

97 Views

Given is the task to show the working of forward_list::cend functions in C++.A forward_list only keeps linkage with the next element unlike normal list that keeps linkage with the next as well as the preceding elements, which helps iterations in both directions. But forward_list can only iterate in the forward direction.The forward_list::cend() function is a part of the C++ standard template library. It is used to obtain the last element of the list. header file should be included to call this function.SyntaxForward_List_Name.cend();ParametersThe function does not accept any parameter.Return ValueThe function returns a constant iterator that points at the last element ... Read More

forward_list cbegin() in C++ STL

Sunidhi Bansal
Updated on 20-Jan-2020 10:02:37

69 Views

Given is the task to show the working of forward_list::cbegin() function in C++.A forward_list only keeps linkage with the next element unlike normal list that keeps linkage with the next as well as the preceding elements, which helps iterations in both directions. But forward_list can only iterate in the forward direction.The forward_list::cbegin() function is a part of the C++ standard template library. It is used to obtain the very first element of the list. header file should be included to call the function.SyntaxForward_List_Name.cbegin();ParametersThe function does not accept any parameter.Return ValueThe function returns a constant iterator that point at the first ... Read More

Forward list assign() function in C++ STL

Sunidhi Bansal
Updated on 20-Jan-2020 07:48:14

203 Views

Given is the task to show the working of forward_list assign() function in C++.A forward_list only keeps linkage with the next element unlike normal list that keeps linkage with the next as well as the preceding elements, which helps iterations in forward as well as backward directions. But forward_list can only iterate in the forward direction.The forward_list::assign() function is a part of the C++ standard template library. It is used to insert elements inside a forward list and if the list already contains some elements then they are replaced by the new ones that are added by the user. header ... Read More

Elements present in first array and not in second using STL in C++

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

113 Views

We have two arrays, the task is to compare the two arrays and find the numbers present in first array but not in the second array, using Standard Template Library (STL) in C++.ExampleInput: array1[ ] = {1, 2, 3, 4, 5, 7} array2[ ] = {2, 3, 4, 5, 6, 8} Output: 1, 7 Input: array1[ ] = {1, 20, 33, 45, 67} array2[ ] = {1, 12, 13, 114, 15, 13} Output: 20, 33, 45, 67Approach used in the below program is as follows −In this program we want to find the elements which are present in the first ... Read More

System() Function in C/C++

Sunidhi Bansal
Updated on 06-Sep-2023 21:57:43

35K+ Views

Given the task is to show the working of system() in C/C++.The system() function is a part of the C/C++ standard library. It is used to pass the commands that can be executed in the command processor or the terminal of the operating system, and finally returns the command after it has been completed. or should be included to call this function.SyntaxThe syntax is as follows −int system(char command)This function returns zero if the command is executed without any errors.ExampleInput: system(“date”) Output: The current date is: Fri 12/27/2019Explanation − The following example shows how we can use the system ... Read More

Const cast in C++

Sunidhi Bansal
Updated on 20-Jan-2020 07:47:46

6K+ 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: x = 50 const int* y = &x cout

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

203 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

88 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

145 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

Advertisements