linux环境中运行C语言程序

在linux环境下做运行C语言程序

[root@localhost ~]# cat a.c
#include <stdio.h>

main()

{int grade; char chgrade;

printf("please input a score:");

scanf("%d",&grade);

switch((int)(grade/10))
{
        case 10:
        case 9:
        printf("A\n");
        break;
        case 8:
        case 7:
        printf("B\n");
        break;
        case 6:
        printf("C\n");
        break;
        default:
        printf("D\n");
        break;
}
}

[root@localhost ~]#
 

[root@localhost ~]# gcc -o aa a.c
[root@localhost ~]# ./aa
please input a score:98
A
[root@localhost ~]# ./aa
please input a score:80
B
[root@localhost ~]# ./aa
please input a score:75
B
[root@localhost ~]# ./aa
please input a score:60
C
[root@localhost ~]# ./aa
please input a score:59
D
[root@localhost ~]# ./aa
please input a score:0
D
[root@localhost ~]#
 

你可能感兴趣的:(linux,C语言)