Answer to Question #184065 in C++ for Bilal

Question #184065

Comment this code line by line in simple english

Comment each line and said why we use.

#include <iostream>
 
#include <cmath>
 
using namespace std;
 
 
float distance(int x1, int y1, int x2, int y2)
 
{
 
 
    return sqrt(pow(x2 - x1, 2) +
 
 
                pow(y2 - y1, 2) * 1.0);
 
}
 
 
 
int main()
 
{
 
 
    cout << "DISTANCE IS:"<< distance(3, 4, 4, 3);
 
 
    return 0;
 
}
 




1
Expert's answer
2021-04-22T03:42:33-0400
#include <iostream> //header file for input and output 
 
#include <cmath> //We are using sqrt function
 
using namespace std;
 
 
float distance(int x1, int y1, int x2, int y2) // Function defintion
 
{
 
 
    return sqrt(pow(x2 - x1, 2) +
 
 
                pow(y2 - y1, 2) * 1.0); //returning values to distance function
 
}
 
 
 
int main()  //main function
 
{
 
 
    cout << "DISTANCE IS:"<< distance(3, 4, 4, 3); // function calling and printing output at same time
 
 
    return 0; // function not return any value
 
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS