C语言中函数的问题

来源:百度知道 编辑:UC知道 时间:2024/06/21 11:35:56
老大们,帮我看看下面函数语句是什么意思,我有两条看不懂:
#include<stdio.h>

long cube(long x) 这句看不懂
long input,answer;

int main(void)
{
printf("enter an interger value:" )
scanf ("%d",input);
answer = cube (input) 这句看不懂
printf("\n the cube of %/d.\n,input ,answer); 这句看不懂

return 0;
}

long cube(long x)
{
long x_cubed;
x_cubed=x*x*x
return x_cubed;
}

#include<stdio.h>

long cube(long x) 这句看不懂
long input,answer;

int main(void)
{
printf("enter an interger value:" )
scanf ("%d",input);
answer = cube (input) 这句看不懂 //这里调用函数long cube(long x)
printf("\n the cube of %/d.\n,input ,answer); 这句看不懂 //这是printf输出语句,其中语法错误,可以改为:printf("\n the cube of %ld is %ld.\n",input ,answer);

return 0;
}

long cube(long x)
{
long x_cubed;
x_cubed=x*x*x
return x_cubed;
}

long cube(long x) ;/*声明函数*/

answer = cube (input) ;/*调用前面声明的cube()函数,参数是input,返回值保存到answer中*/

printf("\n the cube of %/d.\n,input ,answer); /*语法错误,原意是要输出input和answer的值*/

函数原型声明,好像少了个分号

printf("\n the cube of %/d.\n,input ,answer);
应为
printf("\n the cube of %ld is %ld.\n",input ,answer);
是1个输出语句

long cube(long