输入字母判断是否为大写

本次所写的文章内容很简单,主要的内容就是了解一下输入一个字母,判断它是否为大小写,而本次还涉及到一个知识getchar(计算机语言函数),那么何为计算机函数?计算机函数有什么作用?简单的说:getcha就是一种读入函数。它从标准输入里读取下一个字符,相当于getc(stdin)。返回类型为int型,为用户输入的ASCII码。想要深入了解,可以访问getchar连接:https://baike.baidu.com/item/getchar/919709?fr=aladdin

(一)代码案例

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(){ 
	char c;
	printf("输入一个字母:\n");
	c = getchar();
	if(c >= 60 && c <= 90)
		printf("%d是大写字母\n",c);
	else
		printf("%d不是大写字母\n",c);
}
 

(二)运行结果

(1)是大写字母

(2)不是大写字母

其实写到此处的时候,还漏说了一个知识点,那就是ASCll,如果想要了解,点击此链接:https://zhidao.baidu.com/question/758097141255030604.html

发布了122 篇原创文章 · 获赞 36 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/qqj3066574300/article/details/103041334
今日推荐