Question: Problem 1 ( Two Intervals ) Write a program called two intervals.cpp that accepts a ( float ) , b ( float ) , d

Problem 1(
Two Intervals
)
Write a program called
two
intervals.cpp
that accepts
a
(float),
b
(float),
d
(float), and
c
(float) as command-line arguments.
The two numbers
a
and
b
represent endpoints of a closed interval (
[a, b]
when
a
b
, or
[b, a]
when
a > b
) on real number line.
The two numbers
c
and
d
represent endpoints of a closed interval (
[c, d]
when
[c
d
, or
[d, c]
when
c > d
) on real number line.
1
Your program will verify then concludes whether or not these two intervals instersect each
other.
Also, your program must display the message Requires 4 arguments to run! if the user
passed less than 4 arguments when running the program.
Here are some example outputs when running the program from a terminal.
/workspace/csc117/hw5
$
g++-o out/two_intervals.out src/two_intervals.cpp 123
$
./out/two_interval.out
Requires 4 arguments to run!
$
./out/two_interval.out -2435
The interval [-2,4] intersects with [3,5]
$
./out/two_interval.out 534-2
The interval [3,5] intersects with [-2,4]
$
./out/two_interval.out 2468
The interval [2,4] does not intersect

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!