C语言中输入大写字母怎么输出成小写字母啊?

Python020

C语言中输入大写字母怎么输出成小写字母啊?,第1张

1、输入字符,可以使用getchar或者scanf的%c格式。

2、在ASCII码表中,对应的小写字母比大写字母大32,所以输出增加32之后的值即可。

3、输出可以使用putchar或者printf。

4、参考代码:

#include <stdio.h>

int main()

{

    char c

    c=getchar()//输入。

    if(c>='A' && c<='Z')//是大写字母

        putchar(c+32)//输出小写。

    return 0

}

如果限定输入为合法大写,不需要判断合法性,那么代码可以简化为:

#include <stdio.h>

int main()

{

    putchar(getchar()+32)//输入,计算,输出,一句即可。

    return 0

}

#include<stdio.h>

int main()

{

int a

char ch

scanf("%d",&a)

ch=a

printf("%c",ch)

return 0

}

扩展资料

#include <stdio.h>

int main()

{

char x,y

scanf("%c",&x)

y=x-32

printf("%c",y)

return 0

}