I'm not too experienced with C, so an explanation might be useful.
正確に何を説明する必要があるのかわからない:
int program (); <-- function prototype for "program" defined here so you can call it in
int main() <-- main.
{
// Display a message
printf("Press 1 to calculate the reduced mass of a molecule or press any other button to exit:");
// store the value typed by the user as a double, also it will accept scientific
// notation (that’s he g part). So you could enter 3.964e+2 if you wanted... an
// int or even a char would have been fine here
scanf ("%lg",&repeat);
Also would this make it so that you can repeat the function as many times as you like?
いいえ、そうではありません。まず、「リピート」の定義がないため、コンパイルされません。第二に、ループメカニズムがありません。for
、、、再帰...多分それが何であれwhile
。do/while
コードは、無限ループで非常に簡単に完了することができます。
int main()
{
double repeat = 0;
for(;;) {
printf("Press 1 to calculate the reduced mass of a molecule or press any other button to exit:");
scanf ("%lg",&repeat);
if(repeat==1)
{
program();
}
else
{
return(0);
}
}
}