10.15实验课作业

#include<stdio.h>
int main(){
    printf("my mul is:202083290296
");
    printf("hello 2020");
    return 0;
}

#include<stdio.h>
int main (){
    while(1)
    printf("0 1 ");
    return 0;
}

#include<stdio.h>
int main(){
    float x,y;
    float a,b,c,e;
    x=1;
    y=2;
    a=x+y;
    b=x-y;
    c=x*y;
    e=x/y;
    printf("a=%f
",a);
    printf("b=%f
",b);
    printf("c=%f
",c);
    printf("e=%f
",e);
    return 0;
}
#include<stdio.h>
int main(){
    float x;
    int y;
    float a,b,c,e;
    x=1;
    y=2;
    a=x+y;
    b=x-y;
    c=x*y;
    e=x/y;
    printf("a=%f
",a);
    printf("b=%f
",b);
    printf("c=%f
",c);
    printf("e=%f
",e);
    return 0;
}

实验报告:

1每句编程语言结束一定要打“;”!!!

2正确的标点符合和关键字系统会用不同颜色显示,方便检查。

3c语言中的除法,如果除数与被除数都为int则商为int, 所以在第三个试验中当x与y被定义为int,e被定义为float时结果为0,因此为了使e得到正确结果x,y都需要为float.

百度资料:当除数和被除数为int时,商为int。当除数与被除数有一个为float 时商为float.所以实验三中插入的两个代码都可以得出上图结果。

原文地址:https://www.cnblogs.com/2967271912lala/p/13823852.html