- Joined
- Dec 4, 2023
- Messages
- 3
- Reaction score
- 0
hello
im trying to learn c++ so i thaught id do the easy stuff on codewars, please can someone help me find out whats wrong with my code. the the quadrant one. i didnt know i knew so little lol its different actually coding and not just following tutorials, ive serched for answers to the errors, these are the ones i couldnt find answers too.
My code:
the errors:
im trying to learn c++ so i thaught id do the easy stuff on codewars, please can someone help me find out whats wrong with my code. the the quadrant one. i didnt know i knew so little lol its different actually coding and not just following tutorials, ive serched for answers to the errors, these are the ones i couldnt find answers too.
My code:
C++:
int quadrent;
int function(int x, int y)
{
if(x > 0 && y > 0)
{
quadrent = 1;
}
else if(x < 0 && y > 0)
{
quadrent = 2;
}
else if(x < 0 && y < 0)
{
quadrent = 3;
}
else if(x > 0 && y < 0)
{
quadrent = 4;
}
}
int main()
{
int function(x, y);
}
the errors:
C++:
In file included from main.cpp:6:
./solution.cpp:20:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
./solution.cpp:23:14: error: C++ requires a type specifier for all declarations
int function(x, y);
^
./solution.cpp:23:17: error: unknown type name 'y'
int function(x, y);
^
In file included from main.cpp:7:
./tests.cpp:3:18: error: use of undeclared identifier 'quadrant'
Assert::That(quadrant(1, 2), Equals(1));
^
./tests.cpp:4:18: error: use of undeclared identifier 'quadrant'
Assert::That(quadrant(3, 5), Equals(1));
^
./tests.cpp:5:18: error: use of undeclared identifier 'quadrant'
Assert::That(quadrant(-10, 100), Equals(2));
^
./tests.cpp:6:18: error: use of undeclared identifier 'quadrant'
Assert::That(quadrant(-1, -9), Equals(3));
^
./tests.cpp:7:18: error: use of undeclared identifier 'quadrant'
Assert::That(quadrant(19, -56), Equals(4));
^
main.cpp:9:5: error: conflicting types for 'main'
int main(int, const char *[]) {
^
./solution.cpp:21:5: note: previous definition is here
int main()
^
1 warning and 8 errors generated.