C程序中error: expected `;' before "scanf"哪里错了?

#include
int main()
{
int R,X,N,A;
printf("请分别输入年息R%,投资X美金,存期N年中的R,X,N的值,并用逗号分隔开:\n")
scanf("%d,%d,%d",&R,&X,&N);
A=X*(1+R/100)^N;
printf("Enter the amout of the initial deposit \n",A);
return 0;
}
哪里错了?

你好,大概看了下你这个程序的目的。前面那个error:expected....意思是 scanf 前缺少分号';'。
后面的程序也有一些问题,我帮你稍微修改了一下:
#include <stdio.h>
#include <math.h>

void main()
{
int R, X, N, A;
double result; //结果是有小数的,不能再用int来存储了。

printf("请分别输入年息R%,投资X美金,存期N年中的R,X,N的值,并用逗号分隔开:\n");

scanf("%d,%d,%d",&R,&X,&N);

result = X * pow((1+R/100.0), N); //这个pow(a,b)函数是用来求a的b次方的。

printf("Enter the amout of the initial deposit %lf \n", result);
}

谢谢。
温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答