美文网首页C语言入门经典
加减乘除的运算(小程序)

加减乘除的运算(小程序)

作者: 全無 | 来源:发表于2016-07-15 21:53 被阅读195次

    计算 a +b

    #include<stdio.h>
    
    int main()
    {
        int a , b;  //容易丢失分号
    
        scanf("%d %d", &a, &b);  //每个语句都以分号结束
        printf("%d\n", a+b);
       
         return 0;
      }
    

    计算 A*B

    版本一

    #include<stdio.h>
    
    int main()
    {
        int a, b;  //容易丢失分号
    
        scanf_s("%d %d", &a, &b);  //每个语句都以分号结束
        printf_s("%d\n", a * b);
    
        return 0;
    }
    
    #include<stdio.h>
    
    int main(void)
    {
        int a  = 0;
        int b  = 0;
    
        printf("请输入A B 两个数 :");
        scanf("%d",A*B);
     //  printf(" %d *%d", a *b);
       //scanf("%d", &);
     
     return 0;
    }
    

    A*B 的程序

     #include <stdio.h>
     int main() 
     {
               double a = 0.0;
               double b = 0.0;
               double result = 0.0;
    
               printf("Please input number a: ");
               scanf("%lf", &a);
    
               printf("Please input number b: ");
               scanf("%lf", &b);
    
               result = a * b;
               printf("%f * %f = %f\n", a, b, result);
               return 0;
       }
    

    相关文章

      网友评论

        本文标题:加减乘除的运算(小程序)

        本文链接:https://www.haomeiwen.com/subject/mhoyjttx.html