in C++ Sample Interaction This is a sample interaction for the program before do
ID: 3673574 • Letter: I
Question
in C++ Sample Interaction This is a sample interaction for the program before doing Task 3: Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop: 4 1 Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop: 1 4 Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop: 10 12 Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop: 1.1 4.5 Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop: 3 10.3 Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop: 10 7 Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop: 0 0
Explanation / Answer
main.cpp
#include <iostream>//header file for input output functions
using namespace std;//The line using namespace std; tells the compiler to use the std namespace
//. Namespaces are a relatively recent addition to C++.
int main ()
{//program starts from main function
int x,y;
do{//do while loop
cout << " Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop:";
cin >> x >> y;
}while(x!=0 && y!=0);
return 0;
}
output
Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop:4 1
Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop:1 4
Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop:10 12
Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop:1.1 4.5
Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop:3 10.3
Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop:10 7
Enter a pair of positive x, then y coordinates, separated by spaces, or '0 0' to stop:0 0
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.