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;
}
#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
}
Comments
Leave a comment