小编Tar*_*ngh的帖子

如何阻止 C 存储悄悄进入操作的值?

我编写了一个简单的程序,将两个数字相乘。当我将它与 scanf 输入相乘时,它会打印出随机答案......

#include<stdio.h>
int main()
{
    int a, b ,c = a * b;
    printf("Type two no.s to be multiplied, ensuring space between them");
    scanf("%d%d", &a, &b);
    printf("The required  output is = %d\n", c);
    return 0;

}

Run Code Online (Sandbox Code Playgroud)

当我输入 8 和 7 时,我得到 4897 作为我的答案,那么答案一定是 56。

c printf initialization scanf

0
推荐指数
2
解决办法
96
查看次数

标签 统计

c ×1

initialization ×1

printf ×1

scanf ×1