Found 7197 Articles for C++

Different ways to declare variable as constant in C and C++

Sunidhi Bansal
Updated on 14-Aug-2020 08:40:57

886 Views

There are multiple ways of declaring constants in C and C++. First of all, we need to understand what constant is.What is a Constant?Constant means which can’t be changed. In terms of programming, constants are the fixed values that are assigned to the variables such that they can’t be altered by any other variable or component during the execution of a program. Constants can be of any data type. They are used in the programming for defining the non-changing component of a program. There are some data or variables which have fixed value like Pi have fixed float value as ... Read More

Upper bound and Lower bound for non increasing vector in C++

Sunidhi Bansal
Updated on 14-Aug-2020 08:31:50

4K+ Views

In this article we are going to discuss the vector::upper_bound() and vector::lower_bound() for an array sorted in non-increasing order in C++ STL.Vectors are similar to the dynamic arrays; they have the ability to modify its size itself whenever a value is inserted into or removed from the container where we are storing the value.In a Vector, lower bound returns an iterator pointing to the first element in the range that does not compare the given value. Upper Bound returns an iterator pointing element in the range that smaller than given value.Input 30 30 30 20 20 20 10 10Output Lower bound of ... Read More

map count( ) function in C++

Sunidhi Bansal
Updated on 14-Aug-2020 08:29:37

5K+ Views

In this article we will be discussing the working, syntax and examples of map::empty() function in C++ STL.What is Map in C++ STL?Maps are the associative container, which facilitates to store the elements formed by a combination on key value and mapped value in a specific order. In a map container the data is internally always sorted with the help of its associated keys. The values in map container is accessed by its unique keys.What is map::count()?The map::count( ) is a function which comes under header file. This function counts the elements with specific key, it returns 1 if ... Read More

Sin( ) function for complex number in C++

Sunidhi Bansal
Updated on 14-Aug-2020 08:27:16

181 Views

We are given with the task to find the working of sin() function for complex number. The sin( ) function for complex numbers are present in the complex header file which means for calculating the value of sin() we need to add the complex header file in the code. In mathematics this function is used to calculate the value of sin having complex numbers.SyntaxSyntax for sin() function is −sin(z);Parameterparameter z can be any complex number and this parameter is defined in the definition of sin() function which makes this parameter mandatory.Return typeThis function returns the complex value of sin( ) ... Read More

Sinh( ) function for complex number in C++

Sunidhi Bansal
Updated on 14-Aug-2020 08:25:45

229 Views

We are given with the task to find the working of sin() function for complex number. The sin( ) function for complex numbers are present in the complex header file which means for calculating the value of sin() we need to add the complex header file in the code. This function is used to calculate the complex hyperbolic sine of complex number.Syntaxtemplate complex Sinh(const complex& x);Parameterparameter z can be any complex number and this parameter is defined in the definition of sin() function which makes this parameter mandatory.Return typeThis function returns the complex value of sin( ) as it contains ... Read More

map max_size() in C++ STL

Sunidhi Bansal
Updated on 14-Aug-2020 08:24:33

1K+ Views

In this article we will be discussing the working, syntax and examples of map::max_size() function in C++ STL.What is a Map in C++ STL?Maps are the associative container, which facilitates to store the elements formed by a combination of key value and mapped value in a specific order. In a map container the data is internally always sorted with the help of its associated keys. The values in the map container are accessed by its unique keys.What is a map::max_size()?map::max_size() function is an inbuilt function in C++ STL, which is defined in header file. max_size() is used to return ... Read More

map::operator[] in C++ STL Program

Sunidhi Bansal
Updated on 14-Aug-2020 08:23:02

452 Views

In this article we will be discussing the working, syntax and example of map equal ‘[]’ operator in C++ STL.What is a Map in C++ STL?Maps are the associative container, which facilitates to store the elements formed by a combination of key value and mapped value in a specific order. In a map container the data is internally always sorted with the help of its associated keys. The values in the map container are accessed by its unique keys.What is a map equal to ‘[]’ operator?map::operator[] is a reference operator. This operator is used to access the element in the ... Read More

iswprint( ) in C++

Sunidhi Bansal
Updated on 14-Aug-2020 08:18:19

81 Views

We are given with the task to show the working of iswprint( ). The iswprint( ) function in C++ STL is used to check that whether the given wide character can be printed or not. It is a function present in cwctype header file in C++. Wide characters is a computer character datatype that generally has a size greater than the traditional 8-bit character.Syntaxint iswprint(c);Parameterc – This is a parameter which specifies the wide character that has to be checked whether it is printable or not.Return ValueThis function returns a non-zero value if c can be printed. It will return ... Read More

Split the sentence into words in C++

Sunidhi Bansal
Updated on 14-Aug-2020 08:14:52

2K+ Views

Given is the task to split the sentence into words. In this, we will separate all the words present in sentence.Input I am a good boyOutput I am a good boyIn the above example we will print the single word in single line.Example#include #include #include Using namespace std; void split( string st){    String word = “ “;    for ( char s : st){       If (s== ‘ ‘){          Cout

sqrt ( ) function for complex number in C++

Sunidhi Bansal
Updated on 14-Aug-2020 08:09:49

553 Views

Given is the task to find the working of sqrt() function for complex number. Basically the sqrt( ) is a function present in complex header file. This function is used to calculate the square root of complex number.Syntaxtemplate complex Sqrt(const complex& x);Parameterx − This parameter x which represent the complex number.Return ValueThis function returns the square root of the complex number.Input  − Sqrt(3,8i)Output − (2.4024,1.6649)Input Sqrt(7,1i)Output − (2.6524,0.1885)Example#include #include Using namespace std; int main( ){    / / Defining of complex Number    Complex x(4,9);    Cout

Advertisements