写一个求两个数的乘积的C语言代码
以下是一个求两个数的乘积的C语言代码的示例:
#include <stdio.h>
int multiply(int num1, int num2) {
int product = num1 * num2;
return product;
}
int main() {
int num1, num2;
printf("Enter two numbers: ");
scanf("%d %d", &num1, &num2);
int result = multiply(num1, num2);
printf("The product of %d and %d is %d\n", num1, num2, result);
return 0;
}
在上面的代码中,multiply函数接收两个整数作为参数,并返回它们的乘积。在main函数中,我们从用户输入获取两个数字,并将它们传递给multiply函数。最后,我们打印出结果。
原文地址: https://www.cveoy.top/t/topic/inbc 著作权归作者所有。请勿转载和采集!