Steps to Execute Flow API in Java 9

raja
Updated on 14-Apr-2020 13:01:43

287 Views

Flow API in Java 9 corresponds to Reactive Streams specification, which is a defacto standard. It contains a minimal set of interfaces that capture the heart of asynchronous publication and subscription.Below are the key interfaces of Flow API:1) Flow.Publisher: It produces items for subscribers to consume, and it contains only method: subscribe(Subscriber), whose purpose should be obvious.Syntaxvoid subscribe(Flow.Subscriber

Find Circumference of a Circle in C++

Ayush Gupta
Updated on 14-Apr-2020 12:23:00

419 Views

In this tutorial, we will be discussing a program to find circumference of a circle.For this we will be provided with the radius of the circle. Our task is to calculate and print the circumference of that circle.Example Live Demo#include using namespace std; #define PI 3.1415 double circumference(double r){    double cir = 2*PI*r;    return cir; } int main(){    double r = 5;    cout

Find Circumcenter of a Triangle in C++

Ayush Gupta
Updated on 14-Apr-2020 12:22:06

567 Views

In this tutorial, we will be discussing a program to find the circumcenter of a triangle.For this we will be provided with three noncollinear points. Our task is to find the circumcenter of the triangle formed by those points.Example Live Demo#include #include using namespace std; //storing X and Y values #define pdd pair void lineFromPoints(pdd P, pdd Q, double &a, double &b, double &c){    a = Q.second - P.second;    b = P.first - Q.first;    c = a*(P.first)+ b*(P.second); } void perpendicularBisectorFromLine(pdd P, pdd Q, double &a, double &b, double &c){    pdd mid_point = make_pair((P.first + ... Read More

Find Century for a Year in C++

Ayush Gupta
Updated on 14-Apr-2020 12:17:53

676 Views

In this tutorial, we will be discussing a program to find the century for a year.For this we will be provided with a year. Our task is to find the century in which the given year falls.Example Live Demo#include using namespace std; void find_century(int year){    //year values can only be positive    if (year

Find Area of a Circular Segment in C++

Ayush Gupta
Updated on 14-Apr-2020 12:15:53

243 Views

In this tutorial, we will be discussing a program to find area of a circular segment.Making a chord in a given sphere divides it into two segments - major and minor. Given the radius of the circle and angle making the minor segment, we are required to find the areas of both segments.Example Live Demo#include using namespace std; float pi = 3.14159; //finding area of segment float area_of_segment(float radius, float angle){    float area_of_sector = pi * (radius * radius)*(angle / 360);    float area_of_triangle = (float)1 / 2 *(radius * radius) *     sin((angle * pi) ... Read More

Partition Point in C++

Ayush Gupta
Updated on 14-Apr-2020 12:13:33

123 Views

In this tutorial, we will be discussing a program to understand partition_point in C++.Partition point is a method which returns an iterator pointing to the first value in a given range. The range is a partitioned one in which the predicate is not true.Example Live Demo#include #include #include bool IsOdd(int i) { return (i % 2) == 1; } int main(){    std::vector data{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };    std::vector odd, even;    std::stable_partition(data.begin(), data.end(), IsOdd);    auto it = std::partition_point(data.begin(), data.end(),    IsOdd);    odd.assign(data.begin(), it);    even.assign(it, data.end());    std::cout

Pair in C++ Standard Template Library (STL)

Ayush Gupta
Updated on 14-Apr-2020 12:11:55

500 Views

In this tutorial, we will be discussing a program to understand pair in C++ Standard Template Library.Pair is a container defined in the utility header that contains two values. It is used to combine two values and associate them even if they are of different types.Example Live Demo#include #include using namespace std; int main(){    //initializing a pair    pair PAIR1 ;    PAIR1.first = 100;    PAIR1.second = 'G' ;    cout

Override Keyword in C++ Programming

Ayush Gupta
Updated on 14-Apr-2020 12:10:44

233 Views

In this tutorial, we will be discussing a program to understand override keyword in C++.Override keyword is used to override the function in a base class and define a separate function with the same signature in the child class.Example Live Demo#include using namespace std; class Base {    public:    //function to be override    virtual void func() {       cout

Output Iterators in C++ Programming

Ayush Gupta
Updated on 14-Apr-2020 12:09:22

148 Views

In this tutorial, we will be discussing a program to understand output iterators in C++.Output iterators are a part of the major five iterators. They function opposite of the input iterators in a way that they can be assigned values but can’t be accessed to fetch values.Example Live Demo#include #include using namespace std; int main(){    vectorv1 = {1, 2, 3, 4, 5};    //declaring iterator    vector::iterator i1;    for (i1=v1.begin();i1!=v1.end();++i1){       *i1 = 1;    }    return 0; }OutputNo output, because we cannot access values of output operators

Ordered Set and GNU C++ PBDS

Ayush Gupta
Updated on 14-Apr-2020 12:07:48

2K+ Views

In this tutorial, we will be discussing a program to understand ordered set and GNU C++ PBDS.Ordered set is a policy based structure other than those in the STL library. The ordered set keeps all the elements in a sorted order and doesn’t allow duplicate values.Example Live Demo#include using namespace std; #include #include using namespace __gnu_pbds; #define ordered_set tree int main(){    //declaring ordered set    ordered_set o_set;    o_set.insert(5);    o_set.insert(1);    o_set.insert(2);    cout

Advertisements