Found 7197 Articles for C++

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

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

189 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

37K+ 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

7K+ 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

279 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

156 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

250 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

115 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

617 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

Advertisements