Junior — Middle
How can an argument be passed to a function during a call?
sobes.tech AI
Answer from AI
Arguments in a C/C++ function are passed when calling the function, enclosed in parentheses after the function name, listing the values or variables that correspond to the function's parameters.
Example:
#include <iostream>
void greet(const char* name) {
std::cout << "Hello, " << name << "!" << std::endl;
}
int main() {
greet("Alice"); // Passing a string literal as an argument
return 0;
}
Here, the argument "Alice" is passed to the greet function during the call. Arguments can be literals, variables, expressions, etc.