#include "windows.h"
#include "stdio.h"
int Add(int a, int b)
{
return a + b;
}
int Sub(int a, int b)
return a - b;
int Mul(int a, int b)
return a * b;
float Div(int a, int b)
if(b == 0) return 0;
return (float)a / b;
void main()
int nNumA = 0, nNumB = 0;
while(TRUE)
printf("輸入數A:");
scanf("%d", &nNumA);
printf("輸入數B:");
scanf("%d", &nNumB);
printf("加法: %d + %d = %d\n",nNumA, nNumB, Add(nNumA, nNumB));
printf("減法: %d - %d = %d\n",nNumA, nNumB, Sub(nNumA, nNumB));
printf("乘法: %d * %d = %d\n",nNumA, nNumB, Mul(nNumA, nNumB));
if(nNumB != 0) printf("除法: %d / %d = %.2f\n",nNumA, nNumB, Div(nNumA, nNumB));
else printf("被除數為0,不能進行除法運算\n");
return ;
#include "windows.h"
#include "stdio.h"
int Add(int a, int b)
{
return a + b;
}
int Sub(int a, int b)
{
return a - b;
}
int Mul(int a, int b)
{
return a * b;
}
float Div(int a, int b)
{
if(b == 0) return 0;
return (float)a / b;
}
void main()
{
int nNumA = 0, nNumB = 0;
while(TRUE)
{
printf("輸入數A:");
scanf("%d", &nNumA);
printf("輸入數B:");
scanf("%d", &nNumB);
printf("加法: %d + %d = %d\n",nNumA, nNumB, Add(nNumA, nNumB));
printf("減法: %d - %d = %d\n",nNumA, nNumB, Sub(nNumA, nNumB));
printf("乘法: %d * %d = %d\n",nNumA, nNumB, Mul(nNumA, nNumB));
if(nNumB != 0) printf("除法: %d / %d = %.2f\n",nNumA, nNumB, Div(nNumA, nNumB));
else printf("被除數為0,不能進行除法運算\n");
}
return ;
}