If the following C++ program is run and the following data isinput, what would i
ID: 3614361 • Letter: I
Question
If the following C++ program is run and the following data isinput, what would it output? Please write everything displayed bythe cout lines.2 4 4 8 4 1 1 2 1 3 3 9 10 -22 2 8 3 3 5 4
#include < iostream >using namespace std;int main(){const int SENTINEL = 0;int c;float n, d, s;float y1, y2, x1, x2;cout << "Enter four numbers (the program terminates when first two are equal): " << endl;cin >> x1 >> x2 >> y1 >> y2;d = static_cast<float>(x2 - x1);n = static_cast<float>(y2 - y1);c = 1;while ( (x2 - x1) != SENTINEL){s = n/d;cout << "Result#" << c << " is " << s << endl;cout << "Enter four numbers (the program terminates when first two are equal): " << endl;cin >> x1 >> x2 >> y1 >> y2;d = static_cast<float>(x2 - x1);n = static_cast<float>(y2 - y1);c = c + 1;}return 0;}
Explanation / Answer
please rate - thanks #include using namespace std;int main(){const int SENTINEL = 0;int c;float n, d, s;float y1, y2, x1, x2;cout > x2 >> y1 >> y2; //this input initializes the loopd = static_cast(x2 - x1);n = static_cast(y2 - y1);c = 1;while ( (x2 - x1) != SENTINEL) // exit when 1st 2 numbers equal{s = n/d; // doing real arithmetic s=(y2-y1)/(x2-x1)== (number 4-number 3)/(number 2-number 1)coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.