Be careful, (x1-x2)^2
will not do an exponent of 2 here. See http://www.cplusplus.com/reference/cmath/pow/.
Second, you probably forgot a +
in your expression:
int distanceFormula(int x1, int y1, int x2, int y2) { double d = sqrt(pow(x1-x2, 2) + pow(y1-y2, 2)); return d; }
Related Posts:
- error: expected unqualified-id error: Meaning and fix? [duplicate]
- c++ compile error: ISO C++ forbids comparison between pointer and integer
- error: redefinition of class
- C++ Error: No match for ‘operator=’
- Identifier not found error on function call
- What is an ‘undeclared identifier’ error and how do I fix it?
- Identifier not found error on function call
- What is an ‘undeclared identifier’ error and how do I fix it?
- C ++ error: a expected initializer before [function name]
- invalid new-expression of abstract class type
- what does “error : a nonstatic member reference must be relative to a specific object” mean?
- “Symbol(s) not found for architecture x86_64” on QtCreator project
- error: redefinition of class
- C++ error: “Array must be initialized with a brace enclosed initializer”
- error: expected primary-expression before ‘)’ token (C)
- what does “error : a nonstatic member reference must be relative to a specific object” mean?
- Resolve build errors due to circular dependency amongst classes
- C++ error: definition of implicitly-declared
- cc1plus: error: unrecognized command line option “-std=c++11” with g++
- extra qualification error in C++
- Cannot open output file, permission denied
- Call to non-static member function without an object argument compiler error
- Error “Unterminated conditional directive” in cross-referencing headers
- multiple definitions error in c++ and solution to solve this issue
- Stray ‘\342’ in C++ program
- System not declared in scope?
- Error in assignment of member in read-only object
- Call of overloaded function is ambiguous
- error: ISO C++ forbids in-class initialization of non-const static member
- Unexpected end of file error
- virtual memory exhausted: Cannot allocate memory
- Compiler error C4430: missing type specifier – int assumed [duplicate]
- Linker Error C++ “undefined reference ” [duplicate]
- convert a char* to std::string
- system(“pause”); – Why is it wrong?
- How to use setprecision in C++
- What is an undefined reference/unresolved external symbol error and how do I fix it?
- Easiest way to convert int to string in C++
- pinpointing “conditional jump or move depends on uninitialized value(s)” valgrind message
- What does the explicit keyword mean?
- program ended prematurely and may have crashed. exit code 0xc0000005
- How to use _CRT_SECURE_NO_WARNINGS
- Stack Memory vs Heap Memory
- Is it more efficient to copy a vector by reserving and copying, or by creating and swapping? [duplicate]
- C++ Singleton design pattern
- How to concatenate a std::string and an int
- Why unsigned int 0xFFFFFFFF is equal to int -1?
- What is the significance of return 0 in C and C++?
- C++ error: terminate called after throwing an instance of ‘std::bad_alloc’
- Why am I getting this redefinition of class error?
- error : expected unqualified-id before return in c++
- math in java – what does ” %” do?
- Unsigned keyword in C++
- How can I solve the error LNK2019: unresolved external symbol – function?
- How to convert a single char into an int [duplicate]
- Exception Handling in C++ Terminate called after throwing an instance of ‘char const*’
- how to define -std=c++11 as default in g++
- “g++” is not recognized as an internal or external command, MinGW
- Is there a function to copy an array in C/C++?
- C++ error: no matching constructor for initialization of
- Examples of good gotos in C or C++
- Sleep function in C++
- Getting error “a nonstatic member reference must be relative to a specific object” while both member are in the same class
- Division in C++
- How to iterate over a vector?
- What are the differences between struct and class in C++?
- How to use glOrtho() in OpenGL?
- error: ‘ostream’ does not name a type
- Remove spaces from std::string in C++
- Read data from a file into an array – C++
- Unknown override specifier, missing type specifier
- error: overloaded ‘operator<<' must be a binary operator (has 3 parameters)
- Process returned -1073741571 (0xC00000FD) on my c++ code
- C++ Why Is There “Unknown Type” When Class Header is Included?
- Invalid conversion from “const char*” to “char” error [duplicate]
- prototype for “….” does not match any in class “…”
- Cannot open Windows.h in Microsoft Visual Studio
- Nested For – Loops to create multiplication table C++
- The system cannot find the file specified. in Visual Studio
- to_string not declared in scope
- C++ Initializing a Global Array
- GCC -fPIC option
- initialize a vector to zeros C++/C++11
- “vector” was not declared in this scope
- non-member function cannot have cv-qualifier
- too many initializers for ‘int [0]’ c++
- function does not take 1 arguments c++
- overloaded function with no contextual type information
- How exactly do lookup tables work and how to implement them?
- Vector declaration “expected parameter declarator”
- C++ Destructors with Vectors, Pointers,
- error C2065: ‘cout’ : undeclared identifier
- How to get the MD5 hash of a file in C++?
- What is the size of sizeof(vector)? C++
- C++ – Print Out Objects From Set
- Why virtual & static keywords aren’t allowed outside class declaration?
- C++ Signed/unsigned mismatch
- What does _T stands for in a CString
- mysql.h file can’t be found
- Getting an error “fopen’: This function or variable may be unsafe.” when compling [duplicate]