C++ Program to Demonstrate using Unary Arithmetic Function Object

This C++ program demonstrates using unary arithmetic function object. Tbe program creates a vector with integer elements and negates them using ‘negate’ function object which is passed as a parameter to the transform algorithm which negates the corresponding elements and stores the value in the second vector. Here is the source code of the C++ … Read more

advertisement

C++ Program to Demonstrate using Multiplies Function Object

This C++ program demonstrates using multiplies arithmetic function object. Tbe program creates two vectors with integer elements and multiplies them using ‘multiplies’ function object which is passed as a parameter to the transform algorithm which multiplies the corresponding elements and stores the product in the third vector. Here is the source code of the C++ … Read more

advertisement

C++ Program to Demonstrate using Binary Arithmetic Function Object

This C++ program demonstrates using binary arithmetic function object. Tbe program creates two vectors with integer elements and adds them using ‘plus’ function object which is passed as a parameter to the transform algorithm which adds the corresponding elements and stores the sum in the third vector. Here is the source code of the C++ … Read more

advertisement

logical_and Predicate Function in C++

This C++ program demonstrates the logical_and() algorithm. The program uses transform function from algorithm library to compute the logical_and of corresponding elements of two vectors by passing logical_and as the binary predicate. The result is stored in the first vector itself. Here is the source code of the C++ program which demonstrates the logical_and() algorithm. … Read more

advertisement

C++ Program to Demonstrate Unary Negater With logical_not Predicate

This C++ program demonstrates the unary negater with logical_not predicate. The program creates a vector, computes logical not of all the elements of the vector and also computes negation of logical not of all elements of the vector. The resulting vectors are then printed on the standard output. Here is the source code of the … Read more

advertisement

C++ Program to Demonstrate Binary Negater With less Predicate

This C++ program demonstrates the binary negater with less predicate. The program creates two vectors and lexicographically compares the two vectors with negated version of less predicate. This results in an inverse effect as without negation. Here is the source code of the C++ program which demonstrates the binary negater with less predicate. The C++ … Read more

advertisement

equal_to Predicate in C++

This C++ program demonstrates the binary negater with equal_to predicate. The program creates two vectors and lexicographically compares the two vectors using negated version of equal_to as a predicate. This results in an inverse effect without negation. Here is the source code of the C++ program which demonstrates the binary negater with equal_to predicate. The … Read more

advertisement

greater_equal in C++

This C++ program implements the greater_equal predicate. The greater_equal predicate is a binary function object which takes two parameters and returns true if first parameter is greater than or equal to the second parameter. We are using this predicate to compare the vectors lexicographically by using lexicographical_compare algorithm and passing greater_equal as the fifth parameter. … Read more

advertisement

unary_function Program in C++

This C++ program illustrates unary function object base. The DivisibleByFour inherits from the unary_function object base defined in functional library and is passed as a predicate to the for_each algorithm. The elements of vector which are divisible by four are printed. Here is the source code of the C++ program illustrates unary function object base. … Read more

advertisement

binary_function Program in C++

This C++ program illustrates binary function object base. The Compare inherits from the binary_function object base defined in functional library. The numbers taken from input are passed to the function object and a boolean result is returned. If the result is true, the numbers are equal otherwise they are unequal. Here is the source code … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.