Multiple choice technology programming languages

I have a function declaration like this(in C/C++).const int f(int* a){ ..... // Do something here return *a; }what is the purpose of the keyword const here?

  1. It is just a fancy keyword, No purpose here

  2. Prevents the compiler from assigning the function as an rvalue

  3. Prevents the compiler from assigning the function as an lvalue

  4. It makes sure that the return value is a const and is not changed by anyone else

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The const keyword before a function's return type (const int f(...)) prevents the function result from being used as an lvalue - you cannot assign to it. This means expressions like f() = 5 would be compile errors. The const refers to the return value being treated as read-only, not that it cannot be modified by others (option D is misleading - the returned value can still be modified if it's a reference/pointer).