做一个字母大小写转换的程序
时间: 2023-03-28 16:02:58 浏览: 73
好的,我可以回答这个问题。以下是一个简单的字母大小写转换的程序:
#include <stdio.h>
#include <ctype.h>
int main() {
char c;
printf("请输入一个字母:");
scanf("%c", &c);
if (islower(c)) {
printf("转换后的字母为:%c\n", toupper(c));
} else if (isupper(c)) {
printf("转换后的字母为:%c\n", tolower(c));
} else {
printf("输入的不是字母!\n");
}
return ;
}
这个程序可以将输入的字母转换为相应的大小写形式。如果输入的是小写字母,则转换为大写字母;如果输入的是大写字母,则转换为小写字母。如果输入的不是字母,则输出提示信息。
相关问题
用C写一个字母大小写转换的程序
好的,以下是用 C 语言编写一个字母大小写转换的程序:
#include <stdio.h>
#include <ctype.h>
int main() {
char c;
printf("请输入一个字母:");
scanf("%c", &c);
if (islower(c)) {
printf("转换后的字母为:%c\n", toupper(c));
} else if (isupper(c)) {
printf("转换后的字母为:%c\n", tolower(c));
} else {
printf("输入的不是字母!\n");
}
return ;
}
当用户输入一个字母后,程序会判断该字母是大写还是小写,然后进行相应的转换。如果用户输入的不是字母,则会提示输入错误。
写一个大小写字母转换的程序
您好,以下是大小写字母转换的程序:
#include <stdio.h>
#include <ctype.h>
int main()
{
char ch;
printf("请输入一个字母:");
scanf("%c", &ch);
if (islower(ch))
{
printf("转换后的字母为:%c\n", toupper(ch));
}
else if (isupper(ch))
{
printf("转换后的字母为:%c\n", tolower(ch));
}
else
{
printf("输入的不是字母!\n");
}
return 0;
}
希望能对您有所帮助。