Server Side Programming Articles - Page 1875 of 2646

difftime() function in C++

Sunidhi Bansal
Updated on 28-Feb-2020 06:02:09

233 Views

In this article we are going to discuss the difftime() function in C++, its syntax, working and its return values.difftime() function is an inbuilt function in C++ which is defined in header file. The function accepts two parameters of time_t type, function calculate the difference between the two timesSyntaxdouble difftime(time_t end, time_t beginning);Return valueReturns the difference of the time in seconds, stored as double data type.Example Live Demo#include #include int main () {    time_t now;    struct tm newyear;    double seconds;    time(&now); /* get current time; */    newyear = *localtime(&now);    newyear.tm_hour = 0; newyear.tm_min ... Read More

isunordered() function in C++

Sunidhi Bansal
Updated on 28-Feb-2020 05:58:15

78 Views

In this article we are going to discuss the isunordered() function in C++, its syntax, working and its return values.isunordered() function is an inbuilt function in C++ which is defined in header file. The function checks whether the two floating points number be NAN, if both or either one of them is NAN then it will return 1(true) else will return 0(false).Syntaxbool isunordered(float n1, float n2);orbool isunordered(double n1, double n2); orbool isunordered(long double n1, long double n2);The function accepts two floating point variables to compare and check if either one of these is nan.Return valueThe function return the boolean value ... Read More

isinf() function in C++

Sunidhi Bansal
Updated on 28-Feb-2020 05:52:53

2K+ Views

In this article we will be discussing the isinf() function in C++, its syntax, working and what will be its return value.isinf() is an inbuilt function in C++ which comes under header file, the function is used to check whether the variable passed in it is infinity or not, no matter if the number is negative infinity or positive infinity. If the number is infinite the function returns a non-zero value (true) and if it is not then it passes zero (false). Also if the number is NAN then also the function will return 0.Syntaxbool isinf(float n);orbool isinf(double n); orbool ... Read More

isfinite() function in C++

Sunidhi Bansal
Updated on 28-Feb-2020 05:48:43

415 Views

In this article we will be discussing the working, syntax and examples of isfinite() function in C++.isfinite() is an inbuilt function in C++ which comes under header file. isfinite() function used to check and return whether the given number is finite or not, a finite number is any floating number which is neither infinite nor NaN (Not a number).Syntaxbool isfinite(float n);orbool isfinite(double n);orbool isfinite(long double n);This function include only 1 parameter n which is the value we have to check for whether it's finite or not.Return valueThe function returns boolean value, 0(false) if the number is not finite and 1(true) ... Read More

fma() function in C++

Sunidhi Bansal
Updated on 28-Feb-2020 05:42:33

84 Views

Given the task is to show the working of fma() function in C++. In this article we will look into what parameters this function need and what results it will be returning.fma() is an inbuilt function of cmath header file, which accepts three parameters x, y and z and return the result x*y+z without losing the precision in any intermediate result.Syntaxfloat fma(float x, float y, float z);Ordouble fma(double x, double y, double z); Orlong double fma(long double x, long double y, long double z);Parametersx − The first element to be multiplied.y − The second element with which x is to ... Read More

deque_crend in C++ in STL

Sunidhi Bansal
Updated on 28-Feb-2020 05:29:25

170 Views

Given is the task to show the functionality of Deque crend( ) function in C++ STLWhat is Deque?Deque is the Double Ended Queues that are the sequence containers which provides the functionality of expansion and contraction on both the ends. A queue data structure allow user to insert data only at the END and delete data from the FRONT. Let’s take the analogy of queues at bus stops where the person can be inserted to a queue from the END only and the person standing in the FRONT is the first to be removed whereas in Double ended queue the ... Read More

deque_emplace in C++ in STL

Sunidhi Bansal
Updated on 28-Feb-2020 05:23:51

209 Views

Given is the task to show the functionality of Deque emplace( ) function in C++ STLWhat is Deque?Deque is the Double Ended Queues that are the sequence containers which provides the functionality of expansion and contraction on both the ends. A queue data structure allow user to insert data only at the END and delete data from the FRONT. Let’s take the analogy of queues at bus stops where the person can be inserted to a queue from the END only and the person standing in the FRONT is the first to be removed whereas in Double ended queue the ... Read More

Find K-Length Substrings With No Repeated Characters in Python

Arnab Chakraborty
Updated on 29-Apr-2020 08:31:57

582 Views

Suppose we have a string S, we have to find the number of substrings of length K where no characters are repeated. So if S = “heyfriendshowareyou” and K is 5, then output will be 15, as the strings are [heyfr, eyfri, yfrie, frien, riend, iends, endsh, ndsho, dshow, showa, howar, oware, warey, areyo, reyou]To solve this, we will follow these steps −create one empty map m, and left := 0 and right := -1 and ans := 0while right < length of string – 1if right – left + 1 = k, thenincrease ans by 1decrease m[str[left]] by 1increase ... Read More

Keys and Rooms in Python

Arnab Chakraborty
Updated on 29-Apr-2020 08:29:03

564 Views

Suppose we have N rooms and we start in room 0. In each room there exists a distinct number in 0, 1, 2, ..., N-1, and each room may have some keys to access the next room. So in other words, each room i has a list of keys rooms[i], and each key rooms[i][j] is an integer in [0, 1, ..., N-1] where N = number of rooms. A key rooms[i][j] = v, this opens the room with number v So if the input is [[1], [2], [3], []]. then output will be true. There are few more points that ... Read More

Max Chunks To Make Sorted in C++

Arnab Chakraborty
Updated on 29-Apr-2020 08:26:16

481 Views

Suppose we gave an array arr that is a permutation of [0, 1, ..., arr.length - 1], we have to split the array into some number of "chunks" or partitions, and individually sort each partition. So after concatenating them, the result will be the sorted array. So if the array is like [1, 0, 2, 3, 4], then the output will be 4, as we can split into two partitions like [1, 0] and [2, 3, 4], but this can also be true that [1, 0], [2], [3], [4]. So this is the highest number of chunks possible, so output ... Read More

Advertisements