int main() {
int a = 2;
int b = 6;
int result = 1; // Initialize the result variable to 1 for multiplication
// Perform multiplication from a to b
for (int i = a; i <= b; i++) {
result *= i;
}
printf("The multiplication result from %d to %d is: %d\n", a, b, result);
return 0;
2条答案
按热度按时间f2uvfpb91#
这是因为在上面的例子中,a(
a++
)增加了两倍。另外,您还混淆了a
和i
。正确的一个是:它打印:
2 * 2 = 4
2 * 3 = 6
2 * 4 = 8
2 * 5 = 10
lnvxswe22#
}