Found 7347 Articles for C++

Sinh( ) function for complex number in C++

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

105 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

363 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

37 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

388 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

Maximum area rectangle by picking four sides from array in C++

Sunidhi Bansal
Updated on 14-Aug-2020 07:50:40

420 Views

The area of the rectangle is calculated as a product of its sides. All rectangles have four sides such that opposite sides are equal. For calculating the area we require length and breadth as two sides. So that we can get desired result −Area rectangle = length X breadthWe are given an array such that it consists of sides of a rectangle. The array contains values for all four sides in random order. The task here is to find two highest pairs of sides from the array in order to get the maximum area possible for the rectangle.Input Arr[] = { ... Read More

Maximum and Minimum element of a linked list which is divisible by a given number k in C++

Sunidhi Bansal
Updated on 14-Aug-2020 07:48:58

119 Views

A linked list is a linear data structure in which elements are linked via pointers. Each element or node of a linked list has a data part and link, or we can say pointer to the next element in sequence. The elements can take noncontiguous locations in memory.We are given a singly linked list in which there is a data part and link to the next element. The other input is a number K. Task is to find the Maximum and Minimum element of a linked list which is divisible by the number K. The linear linked list can only ... Read More

Maximum adjacent difference in an array in its sorted form in C++

Sunidhi Bansal
Updated on 14-Aug-2020 07:45:48

995 Views

We are given with an array. The array need not be sorted. The task is to find the maximum difference between adjacent elements of that array in its sorted form. So the first thing is to sort the array in increasing or decreasing order. Then we will iterate the array and calculate the adjacent difference of Arr[i+1]-Arr[i]. Then for each iteration we will compare this difference with the one which is found maximum so far.Input − Arr[] = [ 1, 5, 10, 2, 7 ]Output − Maximum adjacent difference in array in its sorted form is 3.Explanation − Sorted Arr[] ... Read More

Maximizing Probability of one type from N containers in C++

Sunidhi Bansal
Updated on 14-Aug-2020 07:40:16

85 Views

Probability Pi= (No. of Favourable Outcomes) / (Total no. of Outcomes).Given is a number N which is the number of containers present. And we have N copies of two numbers X and Y. The task is to divide copies of one number X into N containers such that the probability of drawing a copy of X is maximum. From above it can be seen that to maximize Pi, we can either maximize the numerator ( No. of favourable outcomes) or minimize the denominator(Total no. of Outcomes). This can be done in a manner that only one container has a copy ... Read More

Advertisements