63.6k views
3 votes
Write a program that will ask the user for three different numerical values. The program should then decide whether the values are equally spaced. C++

User Peritract
by
6.9k points

1 Answer

3 votes

Answer:

See the code in the Eplanation

Step-by-step explanation:

// Online C++ compiler to run C++ program online

#include <iostream>

using namespace std;

int main() {

int firstNumber;

int secondNumber;

int thirdNumber;

cout<< "Enter the firstNumber: ";

cin >> firstNumber;

cout << "Enter the secondNumer: ";

cin >> secondNumber;

cout << "Enter the thirdNumber: ";

cin >> thirdNumber;

int upperbound= abs(firstNumber-secondNumber);

int lowerbound= abs(secondNumber-thirdNumber);

if (lowerbound==upperbound){

cout << "The Three Numbers are Equally spaced";

}

else{

cout << "The Three Numbers are NOT Equally spaced";

}

}

User Ashish Sarkar
by
8.0k points