Get the answers you need at Westonci.ca, where our expert community is dedicated to providing you with accurate information. Experience the ease of finding accurate answers to your questions from a knowledgeable community of professionals. Join our Q&A platform to connect with experts dedicated to providing accurate answers to your questions in various fields.
Sagot :
Answer:
Following are the code to the given question:
#include<iostream>//header file
#include<math.h>//header file
using namespace std;
int main()//main method
{
long long x, x1, y, y1;//defining long variable
int count=0,i,j;//defining integer variable
cout<<"Enter a range for x coordinates: "<<endl;//print message
cin>>x>>x1;//input x and x1 value
cout<<"Enter a range for y coordinates: "<<endl;//print message
cin>>y>>y1; //input y and y1 value
for(i = x; i <= -x1; i++)//use nested loop that tests each coordinates
{
for(j = y; j <= y1; j++)//use nested loop that tests each coordinates
{
if(((2*pow(i,2)) + abs(2*i*j) + pow(j,2)) == 10000)//use if that checks condition as per the given question
{
cout<<"There is a planet at "<<i<<", "<<j<<endl;// print coordinates
count++;//incrementing count variable value
}
}
}
cout<<"Total number of planets detected are: "<<count<<endl;//print count value
return 0;
}
Explanation:
In this code, inside the main method long "x, x1, y, and y1" and integer "count, i, and j" type variable is declared that uses a long variable to input value from the user-end.
In the next step, two nested loops have defined that test each coordinate and define if block that checks condition as per the given question and use i, j, and count variable to print value with the message.
Thanks for using our service. We're always here to provide accurate and up-to-date answers to all your queries. Thank you for choosing our platform. We're dedicated to providing the best answers for all your questions. Visit us again. We're glad you chose Westonci.ca. Revisit us for updated answers from our knowledgeable team.