晨曦到日暮 发表于 2018-1-9 19:46:50

c语言

10.编写程序,输入两个实数x ,y ,输出x除以y的余数。
#include<stdio.h>
int main()
{
        double x,y,z;
        printf("请输入两个实数x,y:");
        scanf("%l%l",x,y);
        z=x%y;
        printf("x除以y的余数是:%l",&z);
        return 0;
}
G:\新建文件夹\第十题.cpp(7) : error C2296: '%' : illegal, left operand has type 'double'
G:\新建文件夹\第十题.cpp(7) : error C2297: '%' : illegal, right operand has type 'double'
Error executing cl.exe.

qq1242009750 发表于 2018-1-9 20:10:20

更正:
scanf("%lf%lf",&x,&y);
printf("x除以y的余数是:%lf",z);

晨曦到日暮 发表于 2018-1-9 21:05:16

#include<stdio.h>
int main()
{
      double x,y,z;
      printf("请输入两个实数x,y:");
      scanf("%l%l",&x,&y);
      z=x % y;
      printf("x除以y的余数是:%lf",&z);
      return 0;
}

晨曦到日暮 发表于 2018-1-9 21:05:53

晨曦到日暮 发表于 2018-1-9 21:05
#include
int main()
{


C:\Users\Administrator\Desktop\Cpp1.cpp(7) : error C2296: '%' : illegal, left operand has type 'float'
C:\Users\Administrator\Desktop\Cpp1.cpp(7) : error C2297: '%' : illegal, right operand has type 'float'
Error executing cl.exe.

晨曦到日暮 发表于 2018-1-9 21:06:23

还是有错误
页: [1]
查看完整版本: c语言