Looking for reliable answers? Westonci.ca is the ultimate Q&A platform where experts share their knowledge on various topics. Discover the answers you need from a community of experts ready to help you with their knowledge and experience in various fields. Get detailed and accurate answers to your questions from a dedicated community of experts on our Q&A platform.
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.
Thank you for your visit. We are dedicated to helping you find the information you need, whenever you need it. Thanks for using our service. We're always here to provide accurate and up-to-date answers to all your queries. Thank you for visiting Westonci.ca, your go-to source for reliable answers. Come back soon for more expert insights.