c - 无法显示结果

标签 c

我想知道我的代码有什么问题。当用户输入分数时,我无法打印出成绩。这是我的代码:

#include<stdio.h> 
int main() 
{ 
    int x,y,z;
    printf("Enter mark for Bahasa:");
    scanf("%d", &x);
    printf("Enter mark for english:");
    scanf("%d", &y);
    printf("Enter mark for Math:");
    scanf("%d", &z);

    if((x > 75) && ( y > 80) && (z > 60))
        printf(" Grade A");
    else if (( x > 75) && ( y < 80) && (z < 60))
        printf ("Grade B");
    else
        printf("honor");         
}

最佳答案

为您的 printf 添加行尾。像这样:

printf("honor\n");

如果您在命令行中工作,您的 shell 提示符可能会覆盖输出。

关于c - 无法显示结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11894103/

相关文章:

c - C中通过函数跟踪指针对象的方法

c - C 语言编程中的返回值

c - 如何正确提示用户输入,直到他们给出有效响应

c - 如何让线程休眠/阻塞纳秒(或至少毫秒)?

c - 对 doxygen 使用 lint 注释

c - 使用 waitpid 或 sigaction?

python - C/C++ 中的 DNS 解析

c - 如何在 makefile 中编写通用命令?

c - 为什么 C 中运算符之间的关联性不同?

c++ - 有人如何将 double 或 float 除以二的倍数?