Difference Between Two Given Time Periods in C++

Mahesh Parahar
Updated on 15-Apr-2020 08:18:24

486 Views

Problem StatementGiven two time periods in the string 'HH:MM: SS' format. Here 'HH' represents hours, 'MM' represents minutes and 'SS' represents seconds. Find the difference in the same string format between these two time periods.Time period 1 = 8:6:2 Time period 2 = 3:9:3 Time Difference is 4:56:59ExampleFollowing is the program in C++ to find the required output. Live Demo#include using namespace std; int main() {    int hour1, minute1, second1;    int hour2, minute2, second2;    int diff_hour, diff_minute, diff_second;    cout minute1 >> second1;    cout minute2 >> second2;    if(second2 > second1) {     ... Read More

Difference Between Optical Fibre and Coaxial Cable

Mahesh Parahar
Updated on 15-Apr-2020 06:23:19

10K+ Views

Optical fibre and Coaxial cables, both are different types of guided media cables. Optical fibre is made up of plastic and glass and is used to transmits signals in form of light or optics whereas coaxial cable is made using plastic and copper wires and is used to transmits signals in form of electric signals.The following are some of the important differences between Optical fibre and Coaxial cable.Sr. No.KeyOptical FibreCoaxial Cable1Transmission TypeOptical Fibre transmits data/signals in the form of light.The coaxial cable transmits data/signals in the form of electrical signals.2MaterialOptical fibre is made using plastic and glass.Coaxial cable is prepared ... Read More

Different Edit Commands in JShell for Java 9

raja
Updated on 14-Apr-2020 18:13:27

282 Views

JShell is a command-line tool introduced in Java 9 that evaluates declarations, statements, and expressions without the main() method. JShell can set up a text editor called JShell Edit Pad, which allows us to modify the code very easily, and it can be launched using the "/edit" command.Below are the different "/edit" commands used in Jshell./edit /edit [ID] /edit [Code_Name]/edit: This command can be used without an argument, the "/edit" command displays all the active code in the text editor./edit [ID]: This command displays in the text editor the code corresponding to the ID entered./edit [Code_Name]: This comamnd displays in the ... Read More

Get JShell Documentation in Java 9

raja
Updated on 14-Apr-2020 15:06:30

435 Views

Java 9 introduced a new interactive tool called JShell. This tool can be used to execute expressions, classes, interfaces, enums, and etc.The detailed documentation can be available in JShell with full information, as well as the use of its internal commands with the various options. This documentation can be accessed using two commands: "/help" and "/?". JShell's documentation is not only limited to information regarding its internal controls, and also includes Javadoc.In the below code snippet, the result can be obtained by using the "/help" command.jshell> /help |   Type a Java language expression, statement, or declaration. |   Or ... Read More

Steps to Execute Flow API in Java 9

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

318 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

457 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

621 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

701 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

264 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

143 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

Advertisements