#include <math.h>
int main()
{
float a;
scanf("%f",&a);
printf("%f", sqrt(a));
return 0;
}
You can pass compile and link arguments to the C compiler by customising the question (click the "Customise" checkbox), opening the Advanced Customisation section, and setting an appropriate value in the Sandbox > Parameters field. In this case the value you want is
{"linkargs":["-lm"]}
Note that that's an 'el', not a 'one'.
You shouldn't ever need to modify the source code on Jobe.
Richard
Thanks, Richard. It worked.
Is there any way to use M_PI ?
Sure. While editing the question, use Customization and specify Parameters under Advanced Customisation as:
{"linkargs":["-lm"], "compileargs": ["-std=gnu99"] }
Specifying linkargs is essential for math.h, and compileargs is required for M_PI (refer link for details).
Many, many thanks for your last answer it Works perfectly. Now, is there any kind of question in coderunner to process pseudocode ?
There's no built-in question type for this. You can define your own question types but the problem with processing pseudo code is that by its very nature it has no formal specification. It's *pseudo* code. So how would you define whether it was right or not?
You could specify a basic set of pseudo-code control structures that students were obliged to follow and then check for the expected ones but even that's likely to be ill-defined. There are usually multiple ways of solving a problem, and *while* and *for* loops are potentially interchangeable. The principle behind CodeRunner is that correctness is determined by executing the code to see if it does the right thing. That's just not possible with pseudocode.
Although recognize the sqrt function, don't recognizes the pow function, what might be happening?
We need more information to answer this question.
I suggest you first click the Template Debugging checkbox in the question editing form, save the question with validation turned off, then run it from a question preview window. If you study the code that's run, you will likely be able to spot the problem yourself. If not, please paste the code that's being run into your next posting, tell us what question type you're using, and include a screen dump showing what error you're getting, or at least the text of the error message.
Hi, I'm using the c_via_python question type.
Here's the code:The linkargs and compileargs sandbox parameters are relevant to C jobs but you're actually running a Python job. Those parameters aren't relevant to Python.
The c_via_python question type is not intended to be the primary way to run a C program. It's an example of how to implement a different language by writing a Python script to compile and run a program in that new language. The commands to compile and build the C program are embedded within the Python script. If you wish to set compile args and link args for this question type you'll have to insert them into the Python script.
Or you can just go back to using one of the built-in C question types like c_function or c_program, as you apparently were doing at the start of this thread.