c语言编写程序 输入两个整数,计算两数之和

如题所述

十六进制 顾名思义有16个基本元素。
那么因为阿拉伯数字只有10个 所以10进制大于等于10的 用16进制表示 才用到字母abcdef。

14(16)=1*16+4=20(10)
24(8)=2*8+4=20(10)

 方法一:
#include 
void main()
{
int a,b;
printf("Input two integers:");
scanf("%d%d",&a,&b);
printf("和:a+b=%d\n",a+b);
printf("差:a-b=%d\n",a-b);
printf("积:a*b=%d\n",a*b);
printf("商:a/b=%d\n",a/b);
printf("余数:a%b=%d\n",a%b);
}




  方法二:
#include <stdio.h>
int add(int a,int b){
    return a+b;
}
void main(){
    int a,b;
    printf("Please input the value of a:");
    scanf("%d",&a);
    printf("Please input the value of b:");
    scanf("%d",&b);
    printf("%d+%d=%d\n",a,b,add(a,b));
}

温馨提示:答案为网友推荐,仅供参考