/home/ubuntu/Main.cpp:3:15: error: expected unqualified-id before ‘int’ 3 | char register(int weight, double height) { | ^~~/home/ubuntu/Main.cpp:3:15: error: expected ‘)’ before ‘int’ 3 | char register(int weight, double height) { | ~^~~ | )/home/ubuntu/Main.cpp: In function ‘int main()’:/home/ubuntu/Main.cpp:30:16: error: expected primary-expression before ‘register’ 30 | category = register(weight, height); | ^~~~~~~~
Question
/home/ubuntu/Main.cpp:3:15: error: expected unqualified-id before ‘int’ 3 | char register(int weight, double height) { | ^/home/ubuntu/Main.cpp:3:15: error: expected ‘)’ before ‘int’ 3 | char register(int weight, double height) { | ~^ | )/home/ubuntu/Main.cpp: In function ‘int main()’:/home/ubuntu/Main.cpp:30:16: error: expected primary-expression before ‘register’ 30 | category = register(weight, height); | ^~~~~~~~
Solution
The error messages you're seeing are due to the use of the keyword "register" as a function name. In C++, "register" is a keyword and cannot be used as a function name.
Here's how you can fix the issue:
-
Change the function name from "register" to something else. For example, you can change it to "registerUser" or "registerDetails".
-
Update the function call in the main function to match the new function name.
Here's an example of how your code might look after making these changes:
char registerUser(int weight, double height) {
// function implementation
}
int main() {
// ...
category = registerUser(weight, height);
// ...
}
Remember to replace "// function implementation" with your actual function code.
Similar Questions
/home/ubuntu/Main.cpp:22:5: error: expected unqualified-id before ‘delete’ 22 | int delete(){ | ^~~~~~/home/ubuntu/Main.cpp: In function ‘int main()’:/home/ubuntu/Main.cpp:72:13: error: ‘insert’ was not declared in this scope 72 | insert(item); | ^~~~~~/home/ubuntu/Main.cpp:75:63: error: expected primary-expression before ‘)’ token 75 | printf("Element deleted from queue is :%d",delete()); | ^
/home/ubuntu/Main.cpp: In function ‘int main()’:/home/ubuntu/Main.cpp:7:35: error: invalid conversion from ‘const char*’ to ‘char*’ [-fpermissive] 7 | result = (m >= 6.0 && s >= 50.5) ? "Eligible for Next Round" : (m < 6.0 || s < 50.5) ? | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | const char* 8 | "Not Eligible" : "Try again..."; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Compiler Message/home/ubuntu/Main.cpp:20:20: warning: missing terminating " character 20 | printf("Invalid type entered! | ^/home/ubuntu/Main.cpp:20:20: error: missing terminating " character 20 | printf("Invalid type entered! | ^~~~~~~~~~~~~~~~~~~~~~/home/ubuntu/Main.cpp:21:1: warning: missing terminating " character 21 | "); | ^/home/ubuntu/Main.cpp:21:1: error: missing terminating " character 21 | "); | ^~~/home/ubuntu/Main.cpp:27:20: warning: missing terminating " character 27 | printf("Integer: %d | ^/home/ubuntu/Main.cpp:27:20: error: missing terminating " character 27 | printf("Integer: %d | ^~~~~~~~~~~~/home/ubuntu/Main.cpp:28:1: warning: missing terminating " character 28 | ", *(int*)value); | ^/home/ubuntu/Main.cpp:28:1: error: missing terminating " character 28 | ", *(int*)value); | ^~~~~~~~~~~~~~~~~/home/ubuntu/Main.cpp:31:20: warning: missing terminating " character 31 | printf("Float: %.2f | ^/home/ubuntu/Main.cpp:31:20: error: missing terminating " character 31 | printf("Float: %.2f | ^~~~~~~~~~~~/home/ubuntu/Main.cpp:32:1: warning: missing terminating " character 32 | ", *(float*)value); | ^/home/ubuntu/Main.cpp:32:1: error: missing terminating " character 32 | ", *(float*)value); | ^~~~~~~~~~~~~~~~~~~/home/ubuntu/Main.cpp: In function ‘int main()’:/home/ubuntu/Main.cpp:22:13: error: expected primary-expression before ‘return’ 22 | return 0; | ^~~~~~/home/ubuntu/Main.cpp:29:13: error: expected primary-expression before ‘break’ 29 | break; | ^~~~~/home/ubuntu/Main.cpp:33:13: error: expected primary-expression before ‘break’ 33 | break; | ^~~~~Sample TestcaseTestcase 1 - FailedExpected OutputInteger: 4OutputTestcase 2 - FailedExpected OutputFloat: 5.50OutputTestcase 3 - FailedExpected OutputInvalid type entered!
home/ubuntu/Main.cpp: In function ‘int main()’:/home/ubuntu/Main.cpp:60:13: error: ‘exit’ was not declared in this scope 60 | exit(0); | ^~~~
Line 6: Char 16: runtime error: signed integer overflow: 46341 * 46341 cannot be represented in type 'int' (solution.cpp)SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior prog_joined.cpp:15:16
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.